30#ifndef INCLUDE_NLOHMANN_JSON_HPP_
31#define INCLUDE_NLOHMANN_JSON_HPP_
33#define NLOHMANN_JSON_VERSION_MAJOR 3
34#define NLOHMANN_JSON_VERSION_MINOR 10
35#define NLOHMANN_JSON_VERSION_PATCH 4
40#include <initializer_list>
62#include <forward_list>
68#include <unordered_map>
149 static constexpr std::array<std::uint8_t, 9> order = {{
156 const auto l_index =
static_cast<std::size_t
>(lhs);
157 const auto r_index =
static_cast<std::size_t
>(rhs);
158 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
186#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
187#if defined(JSON_HEDLEY_VERSION)
188 #undef JSON_HEDLEY_VERSION
190#define JSON_HEDLEY_VERSION 15
192#if defined(JSON_HEDLEY_STRINGIFY_EX)
193 #undef JSON_HEDLEY_STRINGIFY_EX
195#define JSON_HEDLEY_STRINGIFY_EX(x) #x
197#if defined(JSON_HEDLEY_STRINGIFY)
198 #undef JSON_HEDLEY_STRINGIFY
200#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
202#if defined(JSON_HEDLEY_CONCAT_EX)
203 #undef JSON_HEDLEY_CONCAT_EX
205#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
207#if defined(JSON_HEDLEY_CONCAT)
208 #undef JSON_HEDLEY_CONCAT
210#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
212#if defined(JSON_HEDLEY_CONCAT3_EX)
213 #undef JSON_HEDLEY_CONCAT3_EX
215#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
217#if defined(JSON_HEDLEY_CONCAT3)
218 #undef JSON_HEDLEY_CONCAT3
220#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
222#if defined(JSON_HEDLEY_VERSION_ENCODE)
223 #undef JSON_HEDLEY_VERSION_ENCODE
225#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
227#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
228 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
230#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
232#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
233 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
235#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
237#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
238 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
240#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
242#if defined(JSON_HEDLEY_GNUC_VERSION)
243 #undef JSON_HEDLEY_GNUC_VERSION
245#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
246 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
247#elif defined(__GNUC__)
248 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
251#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
252 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
254#if defined(JSON_HEDLEY_GNUC_VERSION)
255 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
257 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
260#if defined(JSON_HEDLEY_MSVC_VERSION)
261 #undef JSON_HEDLEY_MSVC_VERSION
263#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
264 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
265#elif defined(_MSC_FULL_VER) && !defined(__ICL)
266 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
267#elif defined(_MSC_VER) && !defined(__ICL)
268 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
271#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
272 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
274#if !defined(JSON_HEDLEY_MSVC_VERSION)
275 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
276#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
277 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
278#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
279 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
281 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
284#if defined(JSON_HEDLEY_INTEL_VERSION)
285 #undef JSON_HEDLEY_INTEL_VERSION
287#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
288 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
289#elif defined(__INTEL_COMPILER) && !defined(__ICL)
290 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
293#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
294 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
296#if defined(JSON_HEDLEY_INTEL_VERSION)
297 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
299 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
302#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
303 #undef JSON_HEDLEY_INTEL_CL_VERSION
305#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
306 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
309#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
310 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
312#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
313 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
315 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
318#if defined(JSON_HEDLEY_PGI_VERSION)
319 #undef JSON_HEDLEY_PGI_VERSION
321#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
322 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
325#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
326 #undef JSON_HEDLEY_PGI_VERSION_CHECK
328#if defined(JSON_HEDLEY_PGI_VERSION)
329 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
331 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
334#if defined(JSON_HEDLEY_SUNPRO_VERSION)
335 #undef JSON_HEDLEY_SUNPRO_VERSION
337#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
338 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10)
339#elif defined(__SUNPRO_C)
340 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
341#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
342 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10)
343#elif defined(__SUNPRO_CC)
344 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
347#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
348 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
350#if defined(JSON_HEDLEY_SUNPRO_VERSION)
351 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
353 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
356#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
357 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
359#if defined(__EMSCRIPTEN__)
360 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
363#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
364 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
366#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
367 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
369 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
372#if defined(JSON_HEDLEY_ARM_VERSION)
373 #undef JSON_HEDLEY_ARM_VERSION
375#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
376 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
377#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
378 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
381#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
382 #undef JSON_HEDLEY_ARM_VERSION_CHECK
384#if defined(JSON_HEDLEY_ARM_VERSION)
385 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
387 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
390#if defined(JSON_HEDLEY_IBM_VERSION)
391 #undef JSON_HEDLEY_IBM_VERSION
393#if defined(__ibmxl__)
394 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
395#elif defined(__xlC__) && defined(__xlC_ver__)
396 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
397#elif defined(__xlC__)
398 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
401#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
402 #undef JSON_HEDLEY_IBM_VERSION_CHECK
404#if defined(JSON_HEDLEY_IBM_VERSION)
405 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
407 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
410#if defined(JSON_HEDLEY_TI_VERSION)
411 #undef JSON_HEDLEY_TI_VERSION
414 defined(__TI_COMPILER_VERSION__) && \
416 defined(__TMS470__) || defined(__TI_ARM__) || \
417 defined(__MSP430__) || \
418 defined(__TMS320C2000__) \
420#if (__TI_COMPILER_VERSION__ >= 16000000)
421 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
425#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
426 #undef JSON_HEDLEY_TI_VERSION_CHECK
428#if defined(JSON_HEDLEY_TI_VERSION)
429 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
431 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
434#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
435 #undef JSON_HEDLEY_TI_CL2000_VERSION
437#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
438 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
441#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
442 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
444#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
445 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
447 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
450#if defined(JSON_HEDLEY_TI_CL430_VERSION)
451 #undef JSON_HEDLEY_TI_CL430_VERSION
453#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
454 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
457#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
458 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
460#if defined(JSON_HEDLEY_TI_CL430_VERSION)
461 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
463 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
466#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
467 #undef JSON_HEDLEY_TI_ARMCL_VERSION
469#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
470 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
473#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
474 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
476#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
477 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
479 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
482#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
483 #undef JSON_HEDLEY_TI_CL6X_VERSION
485#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
486 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
489#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
490 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
492#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
493 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
495 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
498#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
499 #undef JSON_HEDLEY_TI_CL7X_VERSION
501#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
502 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
505#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
506 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
508#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
509 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
511 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
514#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
515 #undef JSON_HEDLEY_TI_CLPRU_VERSION
517#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
518 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
521#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
522 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
524#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
525 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
527 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
530#if defined(JSON_HEDLEY_CRAY_VERSION)
531 #undef JSON_HEDLEY_CRAY_VERSION
534 #if defined(_RELEASE_PATCHLEVEL)
535 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
537 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
541#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
542 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
544#if defined(JSON_HEDLEY_CRAY_VERSION)
545 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
547 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
550#if defined(JSON_HEDLEY_IAR_VERSION)
551 #undef JSON_HEDLEY_IAR_VERSION
553#if defined(__IAR_SYSTEMS_ICC__)
555 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
557 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
561#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
562 #undef JSON_HEDLEY_IAR_VERSION_CHECK
564#if defined(JSON_HEDLEY_IAR_VERSION)
565 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
567 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
570#if defined(JSON_HEDLEY_TINYC_VERSION)
571 #undef JSON_HEDLEY_TINYC_VERSION
573#if defined(__TINYC__)
574 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
577#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
578 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
580#if defined(JSON_HEDLEY_TINYC_VERSION)
581 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
583 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
586#if defined(JSON_HEDLEY_DMC_VERSION)
587 #undef JSON_HEDLEY_DMC_VERSION
590 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
593#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
594 #undef JSON_HEDLEY_DMC_VERSION_CHECK
596#if defined(JSON_HEDLEY_DMC_VERSION)
597 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
599 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
602#if defined(JSON_HEDLEY_COMPCERT_VERSION)
603 #undef JSON_HEDLEY_COMPCERT_VERSION
605#if defined(__COMPCERT_VERSION__)
606 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
609#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
610 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
612#if defined(JSON_HEDLEY_COMPCERT_VERSION)
613 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
615 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
618#if defined(JSON_HEDLEY_PELLES_VERSION)
619 #undef JSON_HEDLEY_PELLES_VERSION
622 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
625#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
626 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
628#if defined(JSON_HEDLEY_PELLES_VERSION)
629 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
631 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
634#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
635 #undef JSON_HEDLEY_MCST_LCC_VERSION
637#if defined(__LCC__) && defined(__LCC_MINOR__)
638 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
641#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
642 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
644#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
645 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
647 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
650#if defined(JSON_HEDLEY_GCC_VERSION)
651 #undef JSON_HEDLEY_GCC_VERSION
654 defined(JSON_HEDLEY_GNUC_VERSION) && \
655 !defined(__clang__) && \
656 !defined(JSON_HEDLEY_INTEL_VERSION) && \
657 !defined(JSON_HEDLEY_PGI_VERSION) && \
658 !defined(JSON_HEDLEY_ARM_VERSION) && \
659 !defined(JSON_HEDLEY_CRAY_VERSION) && \
660 !defined(JSON_HEDLEY_TI_VERSION) && \
661 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
662 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
663 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
664 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
665 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
666 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
667 !defined(__COMPCERT__) && \
668 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
669 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
672#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
673 #undef JSON_HEDLEY_GCC_VERSION_CHECK
675#if defined(JSON_HEDLEY_GCC_VERSION)
676 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
678 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
681#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
682 #undef JSON_HEDLEY_HAS_ATTRIBUTE
685 defined(__has_attribute) && \
687 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
689# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
691# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
694#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
695 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
697#if defined(__has_attribute)
698 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
700 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
703#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
704 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
706#if defined(__has_attribute)
707 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
709 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
712#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
713 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
716 defined(__has_cpp_attribute) && \
717 defined(__cplusplus) && \
718 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
719 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
721 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
724#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
725 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
727#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
728 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
730 !defined(JSON_HEDLEY_PGI_VERSION) && \
731 !defined(JSON_HEDLEY_IAR_VERSION) && \
732 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
733 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
734 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
736 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
739#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
740 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
742#if defined(__has_cpp_attribute) && defined(__cplusplus)
743 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
745 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
748#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
749 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
751#if defined(__has_cpp_attribute) && defined(__cplusplus)
752 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
754 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
757#if defined(JSON_HEDLEY_HAS_BUILTIN)
758 #undef JSON_HEDLEY_HAS_BUILTIN
760#if defined(__has_builtin)
761 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
763 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
766#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
767 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
769#if defined(__has_builtin)
770 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
772 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
775#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
776 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
778#if defined(__has_builtin)
779 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
781 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
784#if defined(JSON_HEDLEY_HAS_FEATURE)
785 #undef JSON_HEDLEY_HAS_FEATURE
787#if defined(__has_feature)
788 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
790 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
793#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
794 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
796#if defined(__has_feature)
797 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
799 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
802#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
803 #undef JSON_HEDLEY_GCC_HAS_FEATURE
805#if defined(__has_feature)
806 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
808 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
811#if defined(JSON_HEDLEY_HAS_EXTENSION)
812 #undef JSON_HEDLEY_HAS_EXTENSION
814#if defined(__has_extension)
815 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
817 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
820#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
821 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
823#if defined(__has_extension)
824 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
826 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
829#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
830 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
832#if defined(__has_extension)
833 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
835 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
838#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
839 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
841#if defined(__has_declspec_attribute)
842 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
844 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
847#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
848 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
850#if defined(__has_declspec_attribute)
851 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
853 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
856#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
857 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
859#if defined(__has_declspec_attribute)
860 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
862 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
865#if defined(JSON_HEDLEY_HAS_WARNING)
866 #undef JSON_HEDLEY_HAS_WARNING
868#if defined(__has_warning)
869 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
871 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
874#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
875 #undef JSON_HEDLEY_GNUC_HAS_WARNING
877#if defined(__has_warning)
878 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
880 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
883#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
884 #undef JSON_HEDLEY_GCC_HAS_WARNING
886#if defined(__has_warning)
887 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
889 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
893 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
894 defined(__clang__) || \
895 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
896 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
897 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
898 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
899 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
900 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
901 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
902 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
903 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
904 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
905 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
906 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
907 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
908 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
909 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
910 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
911 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
912#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
913 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
915 #define JSON_HEDLEY_PRAGMA(value)
918#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
919 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
921#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
922 #undef JSON_HEDLEY_DIAGNOSTIC_POP
924#if defined(__clang__)
925 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
926 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
927#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
928 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
929 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
930#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
931 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
932 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
934 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
935 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
936 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
937 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
938#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
939 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
940 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
942 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
943 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
944 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
945 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
946 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
947 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
948 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
949 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
950#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
951 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
952 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
954 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
955 #define JSON_HEDLEY_DIAGNOSTIC_POP
960#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
961 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
963#if defined(__cplusplus)
964# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
965# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
966# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
967# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
968 JSON_HEDLEY_DIAGNOSTIC_PUSH \
969 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
970 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
971 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
973 JSON_HEDLEY_DIAGNOSTIC_POP
975# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
976 JSON_HEDLEY_DIAGNOSTIC_PUSH \
977 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
978 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
980 JSON_HEDLEY_DIAGNOSTIC_POP
983# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
984 JSON_HEDLEY_DIAGNOSTIC_PUSH \
985 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
987 JSON_HEDLEY_DIAGNOSTIC_POP
991#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
992 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
995#if defined(JSON_HEDLEY_CONST_CAST)
996 #undef JSON_HEDLEY_CONST_CAST
998#if defined(__cplusplus)
999# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1001 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1002 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1003 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1004# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1005 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1006 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1008 JSON_HEDLEY_DIAGNOSTIC_POP \
1011# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1014#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1015 #undef JSON_HEDLEY_REINTERPRET_CAST
1017#if defined(__cplusplus)
1018 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1020 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1023#if defined(JSON_HEDLEY_STATIC_CAST)
1024 #undef JSON_HEDLEY_STATIC_CAST
1026#if defined(__cplusplus)
1027 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1029 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1032#if defined(JSON_HEDLEY_CPP_CAST)
1033 #undef JSON_HEDLEY_CPP_CAST
1035#if defined(__cplusplus)
1036# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1037# define JSON_HEDLEY_CPP_CAST(T, expr) \
1038 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1039 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1041 JSON_HEDLEY_DIAGNOSTIC_POP
1042# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1043# define JSON_HEDLEY_CPP_CAST(T, expr) \
1044 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1045 _Pragma("diag_suppress=Pe137") \
1046 JSON_HEDLEY_DIAGNOSTIC_POP
1048# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1051# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1054#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1055 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1057#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1058 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1059#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1060 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1061#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1062 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1063#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1064 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1065#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1066 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1067#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1068 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1069#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1070 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1071#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1072 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1074 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1075 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1076 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1077 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1078 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1079 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1080 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1081 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1082 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1083 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1084 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1085 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1086#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1087 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1088#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1089 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1090#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1091 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1092#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1093 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1095 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1098#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1099 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1101#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1102 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1103#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1104 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1105#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1106 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1107#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1108 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1109#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1110 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1111#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1112 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1114 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1115 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1116 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1117 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1118 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1119#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1120 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1121#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1122 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1123#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1124 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1126 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1129#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1130 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1132#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1133 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1134#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1135 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1136#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1137 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1138#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1139 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1140#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1141 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1142#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1143 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1144#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1145 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1146#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1147 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1149 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1150 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1151 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1152 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1153#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1154 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1155#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1156 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1158 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1161#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1162 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1164#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1165 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1166#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1167 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1168#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1169 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1171 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1174#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1175 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1177#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1178 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1179#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1180 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1181#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1182 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1183#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1184 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1186 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1189#if defined(JSON_HEDLEY_DEPRECATED)
1190 #undef JSON_HEDLEY_DEPRECATED
1192#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1193 #undef JSON_HEDLEY_DEPRECATED_FOR
1196 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1197 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1198 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1199 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1201 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1202 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1203 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1204 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1205 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1206 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1207 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1208 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1209 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1210 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1211 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1212 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1213 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1214 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1215#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1216 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1217 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1219 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1220 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1221 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1222 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1223 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1224 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1225 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1226 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1227 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1228 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1229 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1230 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1231 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1232 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1233 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1234 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1235 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1236 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1238 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1239 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1240 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1241 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1242 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1243#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1244 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1245 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1247 #define JSON_HEDLEY_DEPRECATED(since)
1248 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1251#if defined(JSON_HEDLEY_UNAVAILABLE)
1252 #undef JSON_HEDLEY_UNAVAILABLE
1255 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1256 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1257 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1258 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1259 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1261 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1264#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1265 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1267#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1268 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1271 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1272 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1273 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1274 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1275 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1276 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1277 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1278 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1279 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1280 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1281 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1282 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1283 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1284 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1285 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1286 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1287 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1288 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1289 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1290#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1291 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1292 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1293#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1294 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1295 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1296#elif defined(_Check_return_)
1297 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1298 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1300 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1301 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1304#if defined(JSON_HEDLEY_SENTINEL)
1305 #undef JSON_HEDLEY_SENTINEL
1308 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1309 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1310 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1311 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1312 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1313 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1315 #define JSON_HEDLEY_SENTINEL(position)
1318#if defined(JSON_HEDLEY_NO_RETURN)
1319 #undef JSON_HEDLEY_NO_RETURN
1321#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1322 #define JSON_HEDLEY_NO_RETURN __noreturn
1324 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1325 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1326 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1327#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1328 #define JSON_HEDLEY_NO_RETURN _Noreturn
1329#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1330 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1332 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1333 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1334 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1335 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1336 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1337 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1338 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1339 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1340 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1341 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1342 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1343 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1344 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1345 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1346 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1347 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1348 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1349 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1350#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1351 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1353 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1354 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1355 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1356#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1357 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1358#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1359 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1360#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1361 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1363 #define JSON_HEDLEY_NO_RETURN
1366#if defined(JSON_HEDLEY_NO_ESCAPE)
1367 #undef JSON_HEDLEY_NO_ESCAPE
1369#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1370 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1372 #define JSON_HEDLEY_NO_ESCAPE
1375#if defined(JSON_HEDLEY_UNREACHABLE)
1376 #undef JSON_HEDLEY_UNREACHABLE
1378#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1379 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1381#if defined(JSON_HEDLEY_ASSUME)
1382 #undef JSON_HEDLEY_ASSUME
1385 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1386 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1387 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1388 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1389#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1390 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1392 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1393 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1394 #if defined(__cplusplus)
1395 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1397 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1401 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1402 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1403 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1404 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1405 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1406 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1407 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1408 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1409#elif defined(JSON_HEDLEY_ASSUME)
1410 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1412#if !defined(JSON_HEDLEY_ASSUME)
1413 #if defined(JSON_HEDLEY_UNREACHABLE)
1414 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1416 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1419#if defined(JSON_HEDLEY_UNREACHABLE)
1421 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1422 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1423 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1425 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1428 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1430#if !defined(JSON_HEDLEY_UNREACHABLE)
1431 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1435#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1436 #pragma clang diagnostic ignored "-Wpedantic"
1438#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1439 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1441#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1442 #if defined(__clang__)
1443 #pragma clang diagnostic ignored "-Wvariadic-macros"
1444 #elif defined(JSON_HEDLEY_GCC_VERSION)
1445 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1448#if defined(JSON_HEDLEY_NON_NULL)
1449 #undef JSON_HEDLEY_NON_NULL
1452 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1453 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1454 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1455 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1456 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1458 #define JSON_HEDLEY_NON_NULL(...)
1462#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1463 #undef JSON_HEDLEY_PRINTF_FORMAT
1465#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1466 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1467#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1468 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1470 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1471 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1472 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1473 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1474 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1475 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1476 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1477 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1478 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1479 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1480 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1481 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1482 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1483 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1484 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1485 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1486 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1487 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1488#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1489 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1491 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1494#if defined(JSON_HEDLEY_CONSTEXPR)
1495 #undef JSON_HEDLEY_CONSTEXPR
1497#if defined(__cplusplus)
1498 #if __cplusplus >= 201103L
1499 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1502#if !defined(JSON_HEDLEY_CONSTEXPR)
1503 #define JSON_HEDLEY_CONSTEXPR
1506#if defined(JSON_HEDLEY_PREDICT)
1507 #undef JSON_HEDLEY_PREDICT
1509#if defined(JSON_HEDLEY_LIKELY)
1510 #undef JSON_HEDLEY_LIKELY
1512#if defined(JSON_HEDLEY_UNLIKELY)
1513 #undef JSON_HEDLEY_UNLIKELY
1515#if defined(JSON_HEDLEY_UNPREDICTABLE)
1516 #undef JSON_HEDLEY_UNPREDICTABLE
1518#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1519 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1522 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1523 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1524 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1525# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1526# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1527# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1528# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1529# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1531 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1532 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1533 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1534 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1535 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1536 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1537 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1538 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1539 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1540 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1541 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1542 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1543 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1544 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1545 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1546 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1547# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1548 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1549# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1551 double hedley_probability_ = (probability); \
1552 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1554# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1556 double hedley_probability_ = (probability); \
1557 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1559# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1560# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1562# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1563# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1564# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1565# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1566# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1568#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1569 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1572#if defined(JSON_HEDLEY_MALLOC)
1573 #undef JSON_HEDLEY_MALLOC
1576 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1577 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1578 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1579 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1580 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1581 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1582 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1583 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1584 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1585 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1586 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1587 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1588 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1589 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1590 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1591 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1592 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1593 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1594 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1595#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1596 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1598 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1599 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1600 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1602 #define JSON_HEDLEY_MALLOC
1605#if defined(JSON_HEDLEY_PURE)
1606 #undef JSON_HEDLEY_PURE
1609 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1610 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1611 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1612 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1613 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1614 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1615 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1616 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1617 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1618 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1619 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1620 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1621 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1622 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1623 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1624 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1625 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1626 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1627 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1628# define JSON_HEDLEY_PURE __attribute__((__pure__))
1629#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1630# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1631#elif defined(__cplusplus) && \
1633 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1634 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1635 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1637# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1639# define JSON_HEDLEY_PURE
1642#if defined(JSON_HEDLEY_CONST)
1643 #undef JSON_HEDLEY_CONST
1646 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1647 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1648 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1649 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1650 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1651 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1652 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1653 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1654 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1655 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1656 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1657 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1658 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1659 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1660 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1661 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1662 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1663 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1664 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1665 #define JSON_HEDLEY_CONST __attribute__((__const__))
1667 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1668 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1670 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1673#if defined(JSON_HEDLEY_RESTRICT)
1674 #undef JSON_HEDLEY_RESTRICT
1676#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1677 #define JSON_HEDLEY_RESTRICT restrict
1679 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1680 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1681 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1682 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1683 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1684 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1685 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1686 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1687 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1688 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1689 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1690 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1691 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1692 defined(__clang__) || \
1693 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1694 #define JSON_HEDLEY_RESTRICT __restrict
1695#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1696 #define JSON_HEDLEY_RESTRICT _Restrict
1698 #define JSON_HEDLEY_RESTRICT
1701#if defined(JSON_HEDLEY_INLINE)
1702 #undef JSON_HEDLEY_INLINE
1705 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1706 (defined(__cplusplus) && (__cplusplus >= 199711L))
1707 #define JSON_HEDLEY_INLINE inline
1709 defined(JSON_HEDLEY_GCC_VERSION) || \
1710 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1711 #define JSON_HEDLEY_INLINE __inline__
1713 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1714 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1715 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1716 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1717 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1718 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1719 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1720 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1721 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1722 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1723 #define JSON_HEDLEY_INLINE __inline
1725 #define JSON_HEDLEY_INLINE
1728#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1729 #undef JSON_HEDLEY_ALWAYS_INLINE
1732 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1733 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1734 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1735 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1736 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1737 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1738 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1739 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1740 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1741 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1742 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1743 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1744 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1745 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1746 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1747 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1748 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1749 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1750 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1751# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1753 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1754 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1755# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1756#elif defined(__cplusplus) && \
1758 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1759 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1760 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1761 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1762 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1763 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1765# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1766#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1767# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1769# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1772#if defined(JSON_HEDLEY_NEVER_INLINE)
1773 #undef JSON_HEDLEY_NEVER_INLINE
1776 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1777 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1778 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1779 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1780 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1781 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1782 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1783 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1784 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1785 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1786 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1787 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1788 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1789 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1790 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1791 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1792 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1793 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1794 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1795 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1797 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1798 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1799 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1800#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1801 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1802#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1803 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1804#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1805 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1806#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1807 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1808#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1809 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1811 #define JSON_HEDLEY_NEVER_INLINE
1814#if defined(JSON_HEDLEY_PRIVATE)
1815 #undef JSON_HEDLEY_PRIVATE
1817#if defined(JSON_HEDLEY_PUBLIC)
1818 #undef JSON_HEDLEY_PUBLIC
1820#if defined(JSON_HEDLEY_IMPORT)
1821 #undef JSON_HEDLEY_IMPORT
1823#if defined(_WIN32) || defined(__CYGWIN__)
1824# define JSON_HEDLEY_PRIVATE
1825# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1826# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1829 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1830 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1831 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1832 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1833 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1834 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1836 defined(__TI_EABI__) && \
1838 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1839 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1842 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1843# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1844# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1846# define JSON_HEDLEY_PRIVATE
1847# define JSON_HEDLEY_PUBLIC
1849# define JSON_HEDLEY_IMPORT extern
1852#if defined(JSON_HEDLEY_NO_THROW)
1853 #undef JSON_HEDLEY_NO_THROW
1856 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
1857 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1858 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1859 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1860 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
1862 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
1863 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1864 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1865 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
1867 #define JSON_HEDLEY_NO_THROW
1870#if defined(JSON_HEDLEY_FALL_THROUGH)
1871 #undef JSON_HEDLEY_FALL_THROUGH
1874 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
1875 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
1876 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1877 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
1878#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
1879 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
1880#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
1881 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
1882#elif defined(__fallthrough)
1883 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
1885 #define JSON_HEDLEY_FALL_THROUGH
1888#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
1889 #undef JSON_HEDLEY_RETURNS_NON_NULL
1892 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
1893 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1894 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1895 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
1896#elif defined(_Ret_notnull_)
1897 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
1899 #define JSON_HEDLEY_RETURNS_NON_NULL
1902#if defined(JSON_HEDLEY_ARRAY_PARAM)
1903 #undef JSON_HEDLEY_ARRAY_PARAM
1906 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
1907 !defined(__STDC_NO_VLA__) && \
1908 !defined(__cplusplus) && \
1909 !defined(JSON_HEDLEY_PGI_VERSION) && \
1910 !defined(JSON_HEDLEY_TINYC_VERSION)
1911 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
1913 #define JSON_HEDLEY_ARRAY_PARAM(name)
1916#if defined(JSON_HEDLEY_IS_CONSTANT)
1917 #undef JSON_HEDLEY_IS_CONSTANT
1919#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
1920 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
1924#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1925 #undef JSON_HEDLEY_IS_CONSTEXPR_
1928 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
1929 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1930 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1931 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
1932 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1933 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1934 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1935 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
1936 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1937 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1938 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
1940#if !defined(__cplusplus)
1942 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
1943 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1944 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1945 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1946 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1947 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1948 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
1949#if defined(__INTPTR_TYPE__)
1950 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
1953 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
1957 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
1958 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
1959 !defined(JSON_HEDLEY_PGI_VERSION) && \
1960 !defined(JSON_HEDLEY_IAR_VERSION)) || \
1961 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1962 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
1963 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
1964 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1965 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
1966#if defined(__INTPTR_TYPE__)
1967 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
1970 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
1973 defined(JSON_HEDLEY_GCC_VERSION) || \
1974 defined(JSON_HEDLEY_INTEL_VERSION) || \
1975 defined(JSON_HEDLEY_TINYC_VERSION) || \
1976 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
1977 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
1978 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
1979 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
1980 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
1981 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
1983# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
1987 ((void*) ((expr) * 0L) ) : \
1988((struct { char v[sizeof(void) * 2]; } *) 1) \
1994#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
1995 #if !defined(JSON_HEDLEY_IS_CONSTANT)
1996 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
1998 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2000 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2001 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2003 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2006#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2007 #undef JSON_HEDLEY_BEGIN_C_DECLS
2009#if defined(JSON_HEDLEY_END_C_DECLS)
2010 #undef JSON_HEDLEY_END_C_DECLS
2012#if defined(JSON_HEDLEY_C_DECL)
2013 #undef JSON_HEDLEY_C_DECL
2015#if defined(__cplusplus)
2016 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2017 #define JSON_HEDLEY_END_C_DECLS }
2018 #define JSON_HEDLEY_C_DECL extern "C"
2020 #define JSON_HEDLEY_BEGIN_C_DECLS
2021 #define JSON_HEDLEY_END_C_DECLS
2022 #define JSON_HEDLEY_C_DECL
2025#if defined(JSON_HEDLEY_STATIC_ASSERT)
2026 #undef JSON_HEDLEY_STATIC_ASSERT
2029 !defined(__cplusplus) && ( \
2030 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2031 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2032 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2033 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2034 defined(_Static_assert) \
2036# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2038 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2039 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2040 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2041# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2043# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2046#if defined(JSON_HEDLEY_NULL)
2047 #undef JSON_HEDLEY_NULL
2049#if defined(__cplusplus)
2050 #if __cplusplus >= 201103L
2051 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2053 #define JSON_HEDLEY_NULL NULL
2055 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2058 #define JSON_HEDLEY_NULL NULL
2060 #define JSON_HEDLEY_NULL ((void*) 0)
2063#if defined(JSON_HEDLEY_MESSAGE)
2064 #undef JSON_HEDLEY_MESSAGE
2066#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2067# define JSON_HEDLEY_MESSAGE(msg) \
2068 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2069 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2070 JSON_HEDLEY_PRAGMA(message msg) \
2071 JSON_HEDLEY_DIAGNOSTIC_POP
2073 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2074 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2075# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2076#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2077# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2078#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2079# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2080#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2081# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2083# define JSON_HEDLEY_MESSAGE(msg)
2086#if defined(JSON_HEDLEY_WARNING)
2087 #undef JSON_HEDLEY_WARNING
2089#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2090# define JSON_HEDLEY_WARNING(msg) \
2091 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2092 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2093 JSON_HEDLEY_PRAGMA(clang warning msg) \
2094 JSON_HEDLEY_DIAGNOSTIC_POP
2096 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2097 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2098 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2099# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2101 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2102 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2103# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2105# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2108#if defined(JSON_HEDLEY_REQUIRE)
2109 #undef JSON_HEDLEY_REQUIRE
2111#if defined(JSON_HEDLEY_REQUIRE_MSG)
2112 #undef JSON_HEDLEY_REQUIRE_MSG
2114#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2115# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2116# define JSON_HEDLEY_REQUIRE(expr) \
2117 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2118 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2119 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2120 JSON_HEDLEY_DIAGNOSTIC_POP
2121# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2122 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2123 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2124 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2125 JSON_HEDLEY_DIAGNOSTIC_POP
2127# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2128# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2131# define JSON_HEDLEY_REQUIRE(expr)
2132# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2135#if defined(JSON_HEDLEY_FLAGS)
2136 #undef JSON_HEDLEY_FLAGS
2138#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2139 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2141 #define JSON_HEDLEY_FLAGS
2144#if defined(JSON_HEDLEY_FLAGS_CAST)
2145 #undef JSON_HEDLEY_FLAGS_CAST
2147#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2148# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2149 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2150 _Pragma("warning(disable:188)") \
2152 JSON_HEDLEY_DIAGNOSTIC_POP \
2155# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2158#if defined(JSON_HEDLEY_EMPTY_BASES)
2159 #undef JSON_HEDLEY_EMPTY_BASES
2162 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2163 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2164 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2166 #define JSON_HEDLEY_EMPTY_BASES
2171#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2172 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2174#if defined(__clang__)
2175 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2177 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2180#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2181 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2183#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2185#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2186 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2188#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2190#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2191 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2193#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2195#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2196 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2198#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2200#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2201 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2203#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2205#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2206 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2208#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2210#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2211 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2213#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2220#include <type_traits>
2253template<
class Default,
2255 template<
class...>
class Op,
2263template<
class Default,
template<
class...>
class Op,
class... Args>
2270template<
template<
class...>
class Op,
class... Args>
2273template<
template<
class...>
class Op,
class... Args>
2276template<
template<
class...>
class Op,
class... Args>
2279template<
class Default,
template<
class...>
class Op,
class... Args>
2282template<
class Default,
template<
class...>
class Op,
class... Args>
2285template<
class Expected,
template<
class...>
class Op,
class... Args>
2288template<
class To,
template<
class...>
class Op,
class... Args>
2290 std::is_convertible<
detected_t<Op, Args...>, To>;
2299#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2300 #if defined(__clang__)
2301 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2302 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2304 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2305 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2306 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2313#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2314 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2315 #define JSON_HAS_CPP_20
2316 #define JSON_HAS_CPP_17
2317 #define JSON_HAS_CPP_14
2318 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2319 #define JSON_HAS_CPP_17
2320 #define JSON_HAS_CPP_14
2321 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2322 #define JSON_HAS_CPP_14
2325 #define JSON_HAS_CPP_11
2329#if defined(__clang__)
2330 #pragma clang diagnostic push
2331 #pragma clang diagnostic ignored "-Wdocumentation"
2332 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2336#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2337 #define JSON_THROW(exception) throw exception
2338 #define JSON_TRY try
2339 #define JSON_CATCH(exception) catch(exception)
2340 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2343 #define JSON_THROW(exception) std::abort()
2344 #define JSON_TRY if(true)
2345 #define JSON_CATCH(exception) if(false)
2346 #define JSON_INTERNAL_CATCH(exception) if(false)
2350#if defined(JSON_THROW_USER)
2352 #define JSON_THROW JSON_THROW_USER
2354#if defined(JSON_TRY_USER)
2356 #define JSON_TRY JSON_TRY_USER
2358#if defined(JSON_CATCH_USER)
2360 #define JSON_CATCH JSON_CATCH_USER
2361 #undef JSON_INTERNAL_CATCH
2362 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2364#if defined(JSON_INTERNAL_CATCH_USER)
2365 #undef JSON_INTERNAL_CATCH
2366 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2370#if !defined(JSON_ASSERT)
2372 #define JSON_ASSERT(x) assert(x)
2376#if defined(JSON_TESTS_PRIVATE)
2377 #define JSON_PRIVATE_UNLESS_TESTED public
2379 #define JSON_PRIVATE_UNLESS_TESTED private
2387#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2388 template<typename BasicJsonType> \
2389 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2391 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2392 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2393 auto it = std::find_if(std::begin(m), std::end(m), \
2394 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2396 return ej_pair.first == e; \
2398 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2400 template<typename BasicJsonType> \
2401 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2403 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2404 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2405 auto it = std::find_if(std::begin(m), std::end(m), \
2406 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2408 return ej_pair.second == j; \
2410 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2416#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2417 template<template<typename, typename, typename...> class ObjectType, \
2418 template<typename, typename...> class ArrayType, \
2419 class StringType, class BooleanType, class NumberIntegerType, \
2420 class NumberUnsignedType, class NumberFloatType, \
2421 template<typename> class AllocatorType, \
2422 template<typename, typename = void> class JSONSerializer, \
2425#define NLOHMANN_BASIC_JSON_TPL \
2426 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2427 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2428 AllocatorType, JSONSerializer, BinaryType>
2432#define NLOHMANN_JSON_EXPAND( x ) x
2433#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME
2434#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2435 NLOHMANN_JSON_PASTE64, \
2436 NLOHMANN_JSON_PASTE63, \
2437 NLOHMANN_JSON_PASTE62, \
2438 NLOHMANN_JSON_PASTE61, \
2439 NLOHMANN_JSON_PASTE60, \
2440 NLOHMANN_JSON_PASTE59, \
2441 NLOHMANN_JSON_PASTE58, \
2442 NLOHMANN_JSON_PASTE57, \
2443 NLOHMANN_JSON_PASTE56, \
2444 NLOHMANN_JSON_PASTE55, \
2445 NLOHMANN_JSON_PASTE54, \
2446 NLOHMANN_JSON_PASTE53, \
2447 NLOHMANN_JSON_PASTE52, \
2448 NLOHMANN_JSON_PASTE51, \
2449 NLOHMANN_JSON_PASTE50, \
2450 NLOHMANN_JSON_PASTE49, \
2451 NLOHMANN_JSON_PASTE48, \
2452 NLOHMANN_JSON_PASTE47, \
2453 NLOHMANN_JSON_PASTE46, \
2454 NLOHMANN_JSON_PASTE45, \
2455 NLOHMANN_JSON_PASTE44, \
2456 NLOHMANN_JSON_PASTE43, \
2457 NLOHMANN_JSON_PASTE42, \
2458 NLOHMANN_JSON_PASTE41, \
2459 NLOHMANN_JSON_PASTE40, \
2460 NLOHMANN_JSON_PASTE39, \
2461 NLOHMANN_JSON_PASTE38, \
2462 NLOHMANN_JSON_PASTE37, \
2463 NLOHMANN_JSON_PASTE36, \
2464 NLOHMANN_JSON_PASTE35, \
2465 NLOHMANN_JSON_PASTE34, \
2466 NLOHMANN_JSON_PASTE33, \
2467 NLOHMANN_JSON_PASTE32, \
2468 NLOHMANN_JSON_PASTE31, \
2469 NLOHMANN_JSON_PASTE30, \
2470 NLOHMANN_JSON_PASTE29, \
2471 NLOHMANN_JSON_PASTE28, \
2472 NLOHMANN_JSON_PASTE27, \
2473 NLOHMANN_JSON_PASTE26, \
2474 NLOHMANN_JSON_PASTE25, \
2475 NLOHMANN_JSON_PASTE24, \
2476 NLOHMANN_JSON_PASTE23, \
2477 NLOHMANN_JSON_PASTE22, \
2478 NLOHMANN_JSON_PASTE21, \
2479 NLOHMANN_JSON_PASTE20, \
2480 NLOHMANN_JSON_PASTE19, \
2481 NLOHMANN_JSON_PASTE18, \
2482 NLOHMANN_JSON_PASTE17, \
2483 NLOHMANN_JSON_PASTE16, \
2484 NLOHMANN_JSON_PASTE15, \
2485 NLOHMANN_JSON_PASTE14, \
2486 NLOHMANN_JSON_PASTE13, \
2487 NLOHMANN_JSON_PASTE12, \
2488 NLOHMANN_JSON_PASTE11, \
2489 NLOHMANN_JSON_PASTE10, \
2490 NLOHMANN_JSON_PASTE9, \
2491 NLOHMANN_JSON_PASTE8, \
2492 NLOHMANN_JSON_PASTE7, \
2493 NLOHMANN_JSON_PASTE6, \
2494 NLOHMANN_JSON_PASTE5, \
2495 NLOHMANN_JSON_PASTE4, \
2496 NLOHMANN_JSON_PASTE3, \
2497 NLOHMANN_JSON_PASTE2, \
2498 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2499#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2500#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2501#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2502#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2503#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2504#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6)
2505#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7)
2506#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8)
2507#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9)
2508#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10)
2509#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
2510#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
2511#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)
2512#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
2513#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)
2514#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
2515#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
2516#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
2517#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
2518#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
2519#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21)
2520#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
2521#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23)
2522#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24)
2523#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25)
2524#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
2525#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27)
2526#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28)
2527#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29)
2528#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
2529#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31)
2530#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32)
2531#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33)
2532#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34)
2533#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35)
2534#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36)
2535#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37)
2536#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38)
2537#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39)
2538#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40)
2539#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41)
2540#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42)
2541#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43)
2542#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44)
2543#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45)
2544#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46)
2545#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47)
2546#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48)
2547#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49)
2548#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50)
2549#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51)
2550#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52)
2551#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53)
2552#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54)
2553#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55)
2554#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56)
2555#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57)
2556#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58)
2557#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59)
2558#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60)
2559#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
2560#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
2561#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
2563#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2564#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2571#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2572 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2573 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2580#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2581 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2582 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2591#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2592 namespace detail { \
2593 using std::std_name; \
2595 template<typename... T> \
2596 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2599 namespace detail2 { \
2600 struct std_name##_tag \
2604 template<typename... T> \
2605 std_name##_tag std_name(T&&...); \
2607 template<typename... T> \
2608 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2610 template<typename... T> \
2611 struct would_call_std_##std_name \
2613 static constexpr auto const value = ::nlohmann::detail:: \
2614 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2618 template<typename... T> \
2619 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2623#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2624 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2627#if JSON_USE_IMPLICIT_CONVERSIONS
2628 #define JSON_EXPLICIT
2630 #define JSON_EXPLICIT explicit
2633#ifndef JSON_DIAGNOSTICS
2634 #define JSON_DIAGNOSTICS 0
2657 const std::string& t)
2660 for (
auto pos = s.find(f);
2661 pos != std::string::npos;
2662 s.replace(pos, f.size(), t),
2663 pos = s.find(f, pos + t.size()))
2717 constexpr operator size_t()
const
2769 const char*
what() const noexcept
override
2779 exception(
int id_, const
char* what_arg) :
id(id_),
m(what_arg) {}
2781 static std::string
name(
const std::string& ename,
int id_)
2783 return "[json.exception." + ename +
"." + std::to_string(id_) +
"] ";
2786 template<
typename BasicJsonType>
2790 std::vector<std::string> tokens;
2791 for (
const auto* current = &leaf_element; current->m_parent !=
nullptr; current = current->m_parent)
2793 switch (current->m_parent->type())
2797 for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
2799 if (¤t->m_parent->m_value.array->operator[](i) == current)
2801 tokens.emplace_back(std::to_string(i));
2810 for (
const auto& element : *current->m_parent->m_value.object)
2812 if (&element.second == current)
2814 tokens.emplace_back(element.first.c_str());
2839 return "(" + std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
2840 [](
const std::string & a,
const std::string & b)
2842 return a +
"/" + detail::escape(b);
2845 static_cast<void>(leaf_element);
2852 std::runtime_error
m;
2912 template<
typename BasicJsonType>
2920 template<
typename BasicJsonType>
2921 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg,
const BasicJsonType& context)
2924 (byte_ != 0 ? (
" at byte " + std::to_string(byte_)) :
"") +
2926 return {id_, byte_, w.c_str()};
2946 return " at line " + std::to_string(pos.
lines_read + 1) +
2991 template<
typename BasicJsonType>
2995 return {id_, w.c_str()};
3046 template<
typename BasicJsonType>
3050 return {id_, w.c_str()};
3094 template<
typename BasicJsonType>
3098 return {id_, w.c_str()};
3133 template<
typename BasicJsonType>
3137 return {id_, w.c_str()};
3153#include <type_traits>
3165using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
3167#ifdef JSON_HAS_CPP_14
3170using std::enable_if_t;
3171using std::index_sequence;
3172using std::make_index_sequence;
3173using std::index_sequence_for;
3178template<
bool B,
typename T =
void>
3205template <
typename T, T... Ints>
3209 static constexpr std::size_t
size() noexcept
3211 return sizeof...(Ints);
3220template <
size_t... Ints>
3223namespace utility_internal
3226template <
typename Seq,
size_t SeqSize,
size_t Rem>
3230template <
typename T, T... Ints,
size_t SeqSize>
3236template <
typename T, T... Ints,
size_t SeqSize>
3244template <
typename T,
size_t N>
3251template <
typename T>
3266template <
typename T, T N>
3282template <
typename... Ts>
3322#include <type_traits>
3343template<
typename It,
typename =
void>
3346template<
typename It>
3350 typename It::reference, typename It::iterator_category >>
3361template<
typename T,
typename =
void>
3411#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3412#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3434template<
typename T =
void,
typename SFINAE =
void>
3435struct adl_serializer;
3437template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3439 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3440 class StringType = std::string,
class BooleanType = bool,
3441 class NumberIntegerType = std::int64_t,
3442 class NumberUnsignedType = std::uint64_t,
3443 class NumberFloatType = double,
3444 template<
typename U>
class AllocatorType = std::allocator,
3445 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3447 class BinaryType = std::vector<std::uint8_t>>
3461template<
typename BasicJsonType>
3474template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3559template<
typename T,
typename... Args>
3562template<
typename T,
typename... Args>
3565template<
typename T,
typename U>
3569template<
typename BasicJsonType,
typename T,
typename =
void>
3576template <
typename BasicJsonType,
typename T>
3582template<
typename BasicJsonType,
typename T>
3585 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3589 const BasicJsonType&, T&>
::value;
3594template<
typename BasicJsonType,
typename T,
typename =
void>
3597template<
typename BasicJsonType,
typename T>
3600 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3609template<
typename BasicJsonType,
typename T,
typename =
void>
3612template<
typename BasicJsonType,
typename T>
3615 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3630template<
class B1,
class... Bn>
3632: std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
3635template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3640template <
typename T>
3643template <
typename T1,
typename T2>
3645 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3647template <
typename T1,
typename T2>
3649 :
conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3651template <
typename... Ts>
3653 :
conjunction<is_default_constructible<Ts>...> {};
3655template <
typename... Ts>
3657 :
conjunction<is_default_constructible<Ts>...> {};
3660template <
typename T,
typename... Args>
3663template <
typename T1,
typename T2>
3666template <
typename T1,
typename T2>
3669template <
typename... Ts>
3672template <
typename... Ts>
3676template<
typename T,
typename =
void>
3698 using t_ref =
typename std::add_lvalue_reference<T>::type;
3710 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value &&
is_iterator_begin;
3723template<
typename T,
typename =
void>
3729template<
typename BasicJsonType,
typename CompatibleObjectType,
3733template<
typename BasicJsonType,
typename CompatibleObjectType>
3735 BasicJsonType, CompatibleObjectType,
3744 typename CompatibleObjectType::key_type>
::value &&
3746 typename CompatibleObjectType::mapped_type>
::value;
3749template<
typename BasicJsonType,
typename CompatibleObjectType>
3753template<
typename BasicJsonType,
typename ConstructibleObjectType,
3757template<
typename BasicJsonType,
typename ConstructibleObjectType>
3759 BasicJsonType, ConstructibleObjectType,
3767 (std::is_move_assignable<ConstructibleObjectType>::value ||
3768 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3770 typename object_t::key_type>
::value &&
3772 typename object_t::mapped_type,
3773 typename ConstructibleObjectType::mapped_type >
::value)) ||
3775 typename ConstructibleObjectType::mapped_type>
::value ||
3778 typename ConstructibleObjectType::mapped_type >
::value);
3781template<
typename BasicJsonType,
typename ConstructibleObjectType>
3784 ConstructibleObjectType> {};
3786template<
typename BasicJsonType,
typename CompatibleStringType>
3793template<
typename BasicJsonType,
typename ConstructibleStringType>
3798 typename BasicJsonType::string_t>
::value;
3801template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3804template<
typename BasicJsonType,
typename CompatibleArrayType>
3806 BasicJsonType, CompatibleArrayType,
3812 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
3819template<
typename BasicJsonType,
typename CompatibleArrayType>
3823template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3826template<
typename BasicJsonType,
typename ConstructibleArrayType>
3828 BasicJsonType, ConstructibleArrayType,
3830 typename BasicJsonType::value_type>
::value >>
3831 : std::true_type {};
3833template<
typename BasicJsonType,
typename ConstructibleArrayType>
3835 BasicJsonType, ConstructibleArrayType,
3837 typename BasicJsonType::value_type>
::value&&
3840(std::is_move_assignable<ConstructibleArrayType>::value ||
3841 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3847!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
3849 detected_t<range_value_t, ConstructibleArrayType >>
::value >>
3855 typename BasicJsonType::array_t::value_type>
::value ||
3863template<
typename BasicJsonType,
typename ConstructibleArrayType>
3867template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3871template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3873 RealIntegerType, CompatibleNumberIntegerType,
3875 std::is_integral<CompatibleNumberIntegerType>
::value&&
3876 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
3884 CompatibleNumberIntegerType>
::value &&
3885 CompatibleLimits::is_integer &&
3886 RealLimits::is_signed == CompatibleLimits::is_signed;
3889template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3892 CompatibleNumberIntegerType> {};
3894template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3897template<
typename BasicJsonType,
typename CompatibleType>
3899 BasicJsonType, CompatibleType,
3906template<
typename BasicJsonType,
typename CompatibleType>
3910template<
typename T1,
typename T2>
3913template<
typename T1,
typename... Args>
3918template <
typename T>
3928 template <
typename C>
static one test(
decltype(&C::capacity) ) ;
3931 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
3935template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
3938 return static_cast<T
>(
value);
3941template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
3953#ifdef JSON_HAS_CPP_17
3954#include <experimental/filesystem>
3961template<
typename BasicJsonType>
3962void from_json(
const BasicJsonType& j,
typename std::nullptr_t& n)
3972template <
typename BasicJsonType,
typename ArithmeticType,
3973 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
3974 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
3978 switch (
static_cast<value_t>(j))
3982 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
3987 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
3992 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4008template<
typename BasicJsonType>
4009void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
4015 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4018template<
typename BasicJsonType>
4019void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
4025 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4029 typename BasicJsonType,
typename ConstructibleStringType,
4032 !std::is_same<
typename BasicJsonType::string_t,
4033 ConstructibleStringType>
::value,
4035void from_json(
const BasicJsonType& j, ConstructibleStringType& s)
4042 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4045template<
typename BasicJsonType>
4046void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4051template<
typename BasicJsonType>
4052void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4057template<
typename BasicJsonType>
4058void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4063template<
typename BasicJsonType,
typename EnumType,
4064 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4067 typename std::underlying_type<EnumType>::type val;
4069 e =
static_cast<EnumType
>(val);
4073template<
typename BasicJsonType,
typename T,
typename Allocator,
4074 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4075void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
4082 std::transform(j.rbegin(), j.rend(),
4083 std::front_inserter(l), [](
const BasicJsonType & i)
4085 return i.template get<T>();
4090template<
typename BasicJsonType,
typename T,
4091 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4099 std::transform(j.begin(), j.end(), std::begin(l),
4100 [](
const BasicJsonType & elem)
4102 return elem.template get<T>();
4106template<
typename BasicJsonType,
typename T, std::
size_t N>
4108->
decltype(j.template get<T>(), void())
4110 for (std::size_t i = 0; i < N; ++i)
4112 arr[i] = j.at(i).template get<T>();
4116template<
typename BasicJsonType>
4119 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4122template<
typename BasicJsonType,
typename T, std::
size_t N>
4125->
decltype(j.template get<T>(), void())
4127 for (std::size_t i = 0; i < N; ++i)
4129 arr[i] = j.at(i).template get<T>();
4133template<
typename BasicJsonType,
typename ConstructibleArrayType,
4135 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4139 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4140 j.template get<typename ConstructibleArrayType::value_type>(),
4145 ConstructibleArrayType ret;
4146 ret.reserve(j.size());
4147 std::transform(j.begin(), j.end(),
4148 std::inserter(ret, end(ret)), [](
const BasicJsonType & i)
4152 return i.template get<typename ConstructibleArrayType::value_type>();
4154 arr = std::move(ret);
4157template<
typename BasicJsonType,
typename ConstructibleArrayType,
4159 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4166 ConstructibleArrayType ret;
4168 j.begin(), j.end(), std::inserter(ret, end(ret)),
4169 [](
const BasicJsonType & i)
4173 return i.template get<typename ConstructibleArrayType::value_type>();
4175 arr = std::move(ret);
4178template <
typename BasicJsonType,
typename ConstructibleArrayType,
4180 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
4181 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
4183 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
4184 !is_basic_json<ConstructibleArrayType>::value,
4186auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
4188j.template get<typename ConstructibleArrayType::value_type>(),
4199template <
typename BasicJsonType,
typename T, std::size_t... Idx >
4203 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
4206template <
typename BasicJsonType,
typename T, std::
size_t N >
4218template<
typename BasicJsonType>
4219void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
4226 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4229template<
typename BasicJsonType,
typename ConstructibleObjectType,
4230 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
4231void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
4238 ConstructibleObjectType ret;
4239 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4240 using value_type =
typename ConstructibleObjectType::value_type;
4242 inner_object->begin(), inner_object->end(),
4243 std::inserter(ret, ret.begin()),
4244 [](
typename BasicJsonType::object_t::value_type
const & p)
4246 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4248 obj = std::move(ret);
4255template <
typename BasicJsonType,
typename ArithmeticType,
4257 std::is_arithmetic<ArithmeticType>::value&&
4258 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
4259 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
4260 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
4261 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4265 switch (
static_cast<value_t>(j))
4269 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4274 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4279 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4284 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
4299template<
typename BasicJsonType,
typename... Args, std::size_t... Idx>
4302 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
4305template <
typename BasicJsonType,
class A1,
class A2 >
4308 return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
4309 std::forward<BasicJsonType>(j).at(1).template get<A2>()};
4312template<
typename BasicJsonType,
typename A1,
typename A2>
4318template<
typename BasicJsonType,
typename... Args>
4324template<
typename BasicJsonType,
typename... Args>
4330template<
typename BasicJsonType,
typename TupleRelated>
4339 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
4342template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
4344 typename BasicJsonType::string_t, Key >
::value >>
4345void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
4352 for (
const auto& p : j)
4358 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4362template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
4364 typename BasicJsonType::string_t, Key >
::value >>
4365void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
4372 for (
const auto& p : j)
4378 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4382#ifdef JSON_HAS_CPP_17
4383template<
typename BasicJsonType>
4384void from_json(
const BasicJsonType& j, std::experimental::filesystem::path& p)
4390 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4396 template<
typename BasicJsonType,
typename T>
4398 noexcept(
noexcept(
from_json(j, std::forward<T>(val))))
4399 ->
decltype(
from_json(j, std::forward<T>(val)))
4401 return from_json(j, std::forward<T>(val));
4422#include <type_traits>
4447template<
typename string_type>
4451 using std::to_string;
4462 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::type >::type;
4513 switch (
anchor.m_object->type())
4545 typename IteratorType::reference
value()
const
4578template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
4586template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
4600#if defined(__clang__)
4602 #pragma clang diagnostic push
4603 #pragma clang diagnostic ignored "-Wmismatched-tags"
4605template<
typename IteratorType>
4607 :
public std::integral_constant<std::size_t, 2> {};
4609template<std::
size_t N,
typename IteratorType>
4614 get<N>(std::declval <
4617#if defined(__clang__)
4618 #pragma clang diagnostic pop
4629#ifdef JSON_HAS_CPP_17
4630 #include <experimental/filesystem>
4653 template<
typename BasicJsonType>
4654 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b)
noexcept
4656 j.m_value.destroy(j.m_type);
4659 j.assert_invariant();
4666 template<
typename BasicJsonType>
4667 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
4669 j.m_value.destroy(j.m_type);
4672 j.assert_invariant();
4675 template<
typename BasicJsonType>
4676 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
4678 j.m_value.destroy(j.m_type);
4680 j.m_value = std::move(s);
4681 j.assert_invariant();
4684 template <
typename BasicJsonType,
typename CompatibleStringType,
4685 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
4687 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
4689 j.m_value.destroy(j.m_type);
4691 j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
4692 j.assert_invariant();
4699 template<
typename BasicJsonType>
4700 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
4702 j.m_value.destroy(j.m_type);
4704 j.m_value =
typename BasicJsonType::binary_t(b);
4705 j.assert_invariant();
4708 template<
typename BasicJsonType>
4709 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
4711 j.m_value.destroy(j.m_type);
4713 j.m_value =
typename BasicJsonType::binary_t(std::move(b));
4714 j.assert_invariant();
4721 template<
typename BasicJsonType>
4722 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
4724 j.m_value.destroy(j.m_type);
4727 j.assert_invariant();
4734 template<
typename BasicJsonType>
4735 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
4737 j.m_value.destroy(j.m_type);
4740 j.assert_invariant();
4747 template<
typename BasicJsonType>
4748 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
4750 j.m_value.destroy(j.m_type);
4753 j.assert_invariant();
4760 template<
typename BasicJsonType>
4761 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
4763 j.m_value.destroy(j.m_type);
4767 j.assert_invariant();
4770 template<
typename BasicJsonType>
4771 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
4773 j.m_value.destroy(j.m_type);
4775 j.m_value = std::move(arr);
4777 j.assert_invariant();
4780 template <
typename BasicJsonType,
typename CompatibleArrayType,
4781 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
4783 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
4788 j.m_value.destroy(j.m_type);
4790 j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
4792 j.assert_invariant();
4795 template<
typename BasicJsonType>
4796 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
4798 j.m_value.destroy(j.m_type);
4801 j.m_value.array->reserve(arr.size());
4802 for (
const bool x : arr)
4804 j.m_value.array->push_back(x);
4805 j.set_parent(j.m_value.array->back());
4807 j.assert_invariant();
4810 template<
typename BasicJsonType,
typename T,
4812 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
4814 j.m_value.destroy(j.m_type);
4817 j.m_value.array->resize(arr.size());
4820 std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
4823 j.assert_invariant();
4830 template<
typename BasicJsonType>
4831 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
4833 j.m_value.destroy(j.m_type);
4837 j.assert_invariant();
4840 template<
typename BasicJsonType>
4841 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
4843 j.m_value.destroy(j.m_type);
4845 j.m_value = std::move(obj);
4847 j.assert_invariant();
4850 template <
typename BasicJsonType,
typename CompatibleObjectType,
4851 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value,
int > = 0 >
4852 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
4857 j.m_value.destroy(j.m_type);
4859 j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
4861 j.assert_invariant();
4869template<
typename BasicJsonType,
typename T,
4870 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
4876template<
typename BasicJsonType,
typename CompatibleString,
4877 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
4878void to_json(BasicJsonType& j,
const CompatibleString& s)
4883template<
typename BasicJsonType>
4884void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
4889template<
typename BasicJsonType,
typename FloatType,
4890 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
4891void to_json(BasicJsonType& j, FloatType val)
noexcept
4896template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
4897 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
4898void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
4903template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
4904 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
4905void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
4910template<
typename BasicJsonType,
typename EnumType,
4911 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4912void to_json(BasicJsonType& j, EnumType e)
noexcept
4914 using underlying_type =
typename std::underlying_type<EnumType>::type;
4918template<
typename BasicJsonType>
4919void to_json(BasicJsonType& j,
const std::vector<bool>& e)
4924template <
typename BasicJsonType,
typename CompatibleArrayType,
4925 enable_if_t < is_compatible_array_type<BasicJsonType,
4927 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
4929 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
4930 !is_basic_json<CompatibleArrayType>::value,
4932void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
4937template<
typename BasicJsonType>
4938void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
4943template<
typename BasicJsonType,
typename T,
4944 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
4945void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
4950template<
typename BasicJsonType>
4951void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
4956template <
typename BasicJsonType,
typename CompatibleObjectType,
4957 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
4958void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
4963template<
typename BasicJsonType>
4964void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
4970 typename BasicJsonType,
typename T, std::size_t N,
4971 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
4979template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
4980void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
4982 j = { p.first, p.second };
4986template<
typename BasicJsonType,
typename T,
4987 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>
::value,
int> = 0>
4990 j = { {b.key(), b.value()} };
4993template<
typename BasicJsonType,
typename Tuple, std::size_t... Idx>
4996 j = { std::get<Idx>(t)... };
4999template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
5000void to_json(BasicJsonType& j,
const T& t)
5005#ifdef JSON_HAS_CPP_17
5006template<
typename BasicJsonType>
5007void to_json(BasicJsonType& j,
const std::experimental::filesystem::path& p)
5015 template<
typename BasicJsonType,
typename T>
5016 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
5017 ->
decltype(
to_json(j, std::forward<T>(val)), void())
5019 return to_json(j, std::forward<T>(val));
5041template<
typename ValueType,
typename>
5055 template<
typename BasicJsonType,
typename TargetType = ValueType>
5056 static auto from_json(BasicJsonType && j, TargetType& val)
noexcept(
5057 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
5058 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
5060 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
5075 template<
typename BasicJsonType,
typename TargetType = ValueType>
5080 return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {});
5092 template<
typename BasicJsonType,
typename TargetType = ValueType>
5093 static auto to_json(BasicJsonType& j, TargetType && val)
noexcept(
5094 noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
5095 ->
decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
5097 ::nlohmann::to_json(j, std::forward<TargetType>(val));
5125template<
typename BinaryType>
5166 return !(rhs == *
this);
5284#include <functional>
5297inline std::size_t
combine(std::size_t seed, std::size_t h)
noexcept
5299 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5314template<
typename BasicJsonType>
5315std::size_t
hash(
const BasicJsonType& j)
5317 using string_t =
typename BasicJsonType::string_t;
5318 using number_integer_t =
typename BasicJsonType::number_integer_t;
5319 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5320 using number_float_t =
typename BasicJsonType::number_float_t;
5322 const auto type =
static_cast<std::size_t
>(j.type());
5325 case BasicJsonType::value_t::null:
5326 case BasicJsonType::value_t::discarded:
5331 case BasicJsonType::value_t::object:
5333 auto seed =
combine(type, j.size());
5334 for (
const auto& element : j.items())
5336 const auto h = std::hash<string_t> {}(element.key());
5343 case BasicJsonType::value_t::array:
5345 auto seed =
combine(type, j.size());
5346 for (
const auto& element : j)
5353 case BasicJsonType::value_t::string:
5355 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
5359 case BasicJsonType::value_t::boolean:
5361 const auto h = std::hash<bool> {}(j.template get<bool>());
5365 case BasicJsonType::value_t::number_integer:
5367 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
5371 case BasicJsonType::value_t::number_unsigned:
5373 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
5377 case BasicJsonType::value_t::number_float:
5379 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
5383 case BasicJsonType::value_t::binary:
5385 auto seed =
combine(type, j.get_binary().size());
5386 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
5388 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
5389 for (
const auto byte : j.get_binary())
5391 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
5433#include <type_traits>
5481 return std::fgetc(
m_file);
5510 is->clear(
is->rdstate() & std::ios::eofbit);
5515 :
is(&i),
sb(i.rdbuf())
5524 :
is(rhs.is),
sb(rhs.sb)
5535 auto res =
sb->sbumpc();
5539 is->clear(
is->rdstate() | std::ios::eofbit);
5546 std::istream*
is =
nullptr;
5547 std::streambuf*
sb =
nullptr;
5553template<
typename IteratorType>
5557 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
5567 auto result = std::char_traits<char_type>::to_int_type(*
current);
5572 return std::char_traits<char_type>::eof();
5579 template<
typename BaseInputAdapter,
size_t T>
5589template<
typename BaseInputAdapter,
size_t T>
5592template<
typename BaseInputAdapter>
5597 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5598 size_t& utf8_bytes_index,
5599 size_t& utf8_bytes_filled)
5601 utf8_bytes_index = 0;
5605 utf8_bytes[0] = std::char_traits<char>::eof();
5606 utf8_bytes_filled = 1;
5611 const auto wc = input.get_character();
5616 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5617 utf8_bytes_filled = 1;
5619 else if (wc <= 0x7FF)
5621 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x1Fu));
5622 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5623 utf8_bytes_filled = 2;
5625 else if (wc <= 0xFFFF)
5627 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x0Fu));
5628 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5629 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5630 utf8_bytes_filled = 3;
5632 else if (wc <= 0x10FFFF)
5634 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | ((
static_cast<unsigned int>(wc) >> 18u) & 0x07u));
5635 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 12u) & 0x3Fu));
5636 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5637 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5638 utf8_bytes_filled = 4;
5643 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5644 utf8_bytes_filled = 1;
5650template<
typename BaseInputAdapter>
5655 std::array<std::char_traits<char>::int_type, 4>& utf8_bytes,
5656 size_t& utf8_bytes_index,
5657 size_t& utf8_bytes_filled)
5659 utf8_bytes_index = 0;
5663 utf8_bytes[0] = std::char_traits<char>::eof();
5664 utf8_bytes_filled = 1;
5669 const auto wc = input.get_character();
5674 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5675 utf8_bytes_filled = 1;
5677 else if (wc <= 0x7FF)
5679 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xC0u | ((
static_cast<unsigned int>(wc) >> 6u)));
5680 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5681 utf8_bytes_filled = 2;
5683 else if (0xD800 > wc || wc >= 0xE000)
5685 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xE0u | ((
static_cast<unsigned int>(wc) >> 12u)));
5686 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((
static_cast<unsigned int>(wc) >> 6u) & 0x3Fu));
5687 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (
static_cast<unsigned int>(wc) & 0x3Fu));
5688 utf8_bytes_filled = 3;
5694 const auto wc2 =
static_cast<unsigned int>(input.get_character());
5695 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
5696 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(0xF0u | (charcode >> 18u));
5697 utf8_bytes[1] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 12u) & 0x3Fu));
5698 utf8_bytes[2] =
static_cast<std::char_traits<char>::int_type
>(0x80u | ((charcode >> 6u) & 0x3Fu));
5699 utf8_bytes[3] =
static_cast<std::char_traits<char>::int_type
>(0x80u | (charcode & 0x3Fu));
5700 utf8_bytes_filled = 4;
5704 utf8_bytes[0] =
static_cast<std::char_traits<char>::int_type
>(wc);
5705 utf8_bytes_filled = 1;
5713template<
typename BaseInputAdapter,
typename W
ideCharType>
5727 fill_buffer<sizeof(WideCharType)>();
5749 std::array<std::char_traits<char>::int_type, 4>
utf8_bytes = {{0, 0, 0, 0}};
5758template<
typename IteratorType,
typename Enable =
void>
5762 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5767 return adapter_type(std::move(first), std::move(last));
5781template<
typename IteratorType>
5785 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
5796template<
typename IteratorType>
5800 return factory_type::create(first, last);
5807namespace container_input_adapter_factory_impl
5813template<
typename ContainerType,
typename Enable =
void>
5816template<
typename ContainerType>
5818 void_t<decltype(begin(
std::declval<ContainerType>()), end(std::declval<ContainerType>()))>>
5830template<
typename ContainerType>
5857template <
typename CharT,
5858 typename std::enable_if <
5859 std::is_pointer<CharT>::value&&
5860 !std::is_array<CharT>::value&&
5861 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
5862 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
5866 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
5867 const auto* ptr =
reinterpret_cast<const char*
>(b);
5871template<
typename T, std::
size_t N>
5883 template <
typename CharT,
5884 typename std::enable_if <
5885 std::is_pointer<CharT>::value&&
5886 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
5887 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
5890 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
5892 template<
class IteratorType,
5893 typename std::enable_if<
5894 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
5901 return std::move(ia);
5934template<
typename BasicJsonType>
6038 const std::string& last_token,
6065template<
typename BasicJsonType>
6081 : root(r), allow_exceptions(allow_exceptions_)
6093 handle_value(
nullptr);
6129 handle_value(std::move(val));
6135 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
6139 JSON_THROW(out_of_range::create(408,
"excessive object size: " + std::to_string(len), *ref_stack.back()));
6148 object_element = &(ref_stack.back()->m_value.object->operator[](val));
6154 ref_stack.back()->set_parents();
6155 ref_stack.pop_back();
6161 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
6165 JSON_THROW(out_of_range::create(408,
"excessive array size: " + std::to_string(len), *ref_stack.back()));
6173 ref_stack.back()->set_parents();
6174 ref_stack.pop_back();
6178 template<
class Exception>
6180 const Exception& ex)
6183 static_cast<void>(ex);
6184 if (allow_exceptions)
6203 template<
typename Value>
6207 if (ref_stack.empty())
6209 root = BasicJsonType(std::forward<Value>(v));
6213 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6215 if (ref_stack.back()->is_array())
6217 ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
6218 return &(ref_stack.back()->m_value.array->back());
6223 *object_element = BasicJsonType(std::forward<Value>(v));
6224 return object_element;
6230 std::vector<BasicJsonType*> ref_stack {};
6232 BasicJsonType* object_element =
nullptr;
6234 bool errored =
false;
6236 const bool allow_exceptions =
true;
6239template<
typename BasicJsonType>
6253 const bool allow_exceptions_ =
true)
6254 : root(r), callback(cb), allow_exceptions(allow_exceptions_)
6256 keep_stack.push_back(
true);
6268 handle_value(
nullptr);
6304 handle_value(std::move(val));
6311 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
6312 keep_stack.push_back(keep);
6314 auto val = handle_value(BasicJsonType::value_t::object,
true);
6315 ref_stack.push_back(val.second);
6318 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
6320 JSON_THROW(out_of_range::create(408,
"excessive object size: " + std::to_string(len), *ref_stack.back()));
6328 BasicJsonType k = BasicJsonType(val);
6331 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
6332 key_keep_stack.push_back(keep);
6335 if (keep && ref_stack.back())
6337 object_element = &(ref_stack.back()->m_value.object->operator[](val) =
discarded);
6345 if (ref_stack.back())
6347 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
6354 ref_stack.back()->set_parents();
6360 ref_stack.pop_back();
6361 keep_stack.pop_back();
6363 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
6366 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
6368 if (it->is_discarded())
6370 ref_stack.back()->erase(it);
6381 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
6382 keep_stack.push_back(keep);
6384 auto val = handle_value(BasicJsonType::value_t::array,
true);
6385 ref_stack.push_back(val.second);
6388 if (ref_stack.back() &&
JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
6390 JSON_THROW(out_of_range::create(408,
"excessive array size: " + std::to_string(len), *ref_stack.back()));
6400 if (ref_stack.back())
6402 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
6405 ref_stack.back()->set_parents();
6416 ref_stack.pop_back();
6417 keep_stack.pop_back();
6420 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
6422 ref_stack.back()->m_value.array->pop_back();
6428 template<
class Exception>
6430 const Exception& ex)
6433 static_cast<void>(ex);
6434 if (allow_exceptions)
6462 template<
typename Value>
6463 std::pair<bool, BasicJsonType*>
handle_value(Value&& v,
const bool skip_callback =
false)
6469 if (!keep_stack.back())
6471 return {
false,
nullptr};
6475 auto value = BasicJsonType(std::forward<Value>(v));
6478 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value,
value);
6483 return {
false,
nullptr};
6486 if (ref_stack.empty())
6488 root = std::move(
value);
6489 return {
true, &root};
6494 if (!ref_stack.back())
6496 return {
false,
nullptr};
6500 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6503 if (ref_stack.back()->is_array())
6505 ref_stack.back()->m_value.array->emplace_back(std::move(
value));
6506 return {
true, &(ref_stack.back()->m_value.array->back())};
6513 const bool store_element = key_keep_stack.back();
6514 key_keep_stack.pop_back();
6518 return {
false,
nullptr};
6522 *object_element = std::move(
value);
6523 return {
true, object_element};
6529 std::vector<BasicJsonType*> ref_stack {};
6531 std::vector<bool> keep_stack {};
6533 std::vector<bool> key_keep_stack {};
6535 BasicJsonType* object_element =
nullptr;
6537 bool errored =
false;
6541 const bool allow_exceptions =
true;
6543 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
6546template<
typename BasicJsonType>
6633#include <initializer_list>
6653template<
typename BasicJsonType>
6687 return "<uninitialized>";
6689 return "true literal";
6691 return "false literal";
6693 return "null literal";
6695 return "string literal";
6699 return "number literal";
6713 return "<parse error>";
6715 return "end of input";
6717 return "'[', '{', or a literal";
6720 return "unknown token";
6730template<
typename BasicJsonType,
typename InputAdapterType>
6743 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
6744 :
ia(
std::move(adapter))
6765 const auto* loc = localeconv();
6767 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
6795 const auto factors = { 12u, 8u, 4u, 0u };
6796 for (
const auto factor : factors)
6802 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x30u) << factor);
6806 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x37u) << factor);
6810 codepoint +=
static_cast<int>((
static_cast<unsigned int>(
current) - 0x57u) << factor);
6818 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
6839 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
6842 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
6888 case std::char_traits<char_type>::eof():
6891 return token_type::parse_error;
6897 return token_type::value_string;
6942 int codepoint = codepoint1;
6946 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
6947 return token_type::parse_error;
6951 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
6960 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
6961 return token_type::parse_error;
6968 codepoint =
static_cast<int>(
6970 (
static_cast<unsigned int>(codepoint1) << 10u)
6972 +
static_cast<unsigned int>(codepoint2)
6980 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6981 return token_type::parse_error;
6986 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
6987 return token_type::parse_error;
6994 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
6995 return token_type::parse_error;
7000 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7003 if (codepoint < 0x80)
7008 else if (codepoint <= 0x7FF)
7011 add(
static_cast<char_int_type>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7012 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7014 else if (codepoint <= 0xFFFF)
7017 add(
static_cast<char_int_type>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7018 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7019 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7024 add(
static_cast<char_int_type>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7025 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7026 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7027 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7035 error_message =
"invalid string: forbidden character after backslash";
7036 return token_type::parse_error;
7045 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7046 return token_type::parse_error;
7051 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7052 return token_type::parse_error;
7057 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7058 return token_type::parse_error;
7063 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7064 return token_type::parse_error;
7069 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7070 return token_type::parse_error;
7075 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7076 return token_type::parse_error;
7081 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7082 return token_type::parse_error;
7087 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7088 return token_type::parse_error;
7093 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7094 return token_type::parse_error;
7099 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7100 return token_type::parse_error;
7105 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7106 return token_type::parse_error;
7111 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7112 return token_type::parse_error;
7117 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7118 return token_type::parse_error;
7123 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7124 return token_type::parse_error;
7129 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7130 return token_type::parse_error;
7135 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7136 return token_type::parse_error;
7141 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7142 return token_type::parse_error;
7147 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7148 return token_type::parse_error;
7153 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7154 return token_type::parse_error;
7159 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7160 return token_type::parse_error;
7165 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7166 return token_type::parse_error;
7171 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7172 return token_type::parse_error;
7177 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7178 return token_type::parse_error;
7183 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7184 return token_type::parse_error;
7189 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7190 return token_type::parse_error;
7195 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7196 return token_type::parse_error;
7201 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7202 return token_type::parse_error;
7207 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7208 return token_type::parse_error;
7213 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7214 return token_type::parse_error;
7219 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7220 return token_type::parse_error;
7225 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7226 return token_type::parse_error;
7231 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7232 return token_type::parse_error;
7369 return token_type::parse_error;
7379 return token_type::parse_error;
7403 return token_type::parse_error;
7413 return token_type::parse_error;
7423 return token_type::parse_error;
7435 return token_type::parse_error;
7445 return token_type::parse_error;
7454 return token_type::parse_error;
7477 case std::char_traits<char_type>::eof():
7494 case std::char_traits<char_type>::eof():
7525 error_message =
"invalid comment; expecting '/' or '*' after '/'";
7532 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
7534 f = std::strtof(str, endptr);
7538 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
7540 f = std::strtod(str, endptr);
7544 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
7546 f = std::strtold(str, endptr);
7596 token_type number_type = token_type::value_unsigned;
7604 goto scan_number_minus;
7610 goto scan_number_zero;
7624 goto scan_number_any1;
7634 number_type = token_type::value_integer;
7640 goto scan_number_zero;
7654 goto scan_number_any1;
7660 return token_type::parse_error;
7671 goto scan_number_decimal1;
7678 goto scan_number_exponent;
7682 goto scan_number_done;
7701 goto scan_number_any1;
7707 goto scan_number_decimal1;
7714 goto scan_number_exponent;
7718 goto scan_number_done;
7721scan_number_decimal1:
7723 number_type = token_type::value_float;
7738 goto scan_number_decimal2;
7744 return token_type::parse_error;
7748scan_number_decimal2:
7764 goto scan_number_decimal2;
7771 goto scan_number_exponent;
7775 goto scan_number_done;
7778scan_number_exponent:
7780 number_type = token_type::value_float;
7787 goto scan_number_sign;
7802 goto scan_number_any2;
7808 "invalid number; expected '+', '-', or digit after exponent";
7809 return token_type::parse_error;
7829 goto scan_number_any2;
7834 error_message =
"invalid number; expected digit after exponent sign";
7835 return token_type::parse_error;
7855 goto scan_number_any2;
7859 goto scan_number_done;
7867 char* endptr =
nullptr;
7871 if (number_type == token_type::value_unsigned)
7873 const auto x = std::strtoull(
token_buffer.data(), &endptr, 10);
7883 return token_type::value_unsigned;
7887 else if (number_type == token_type::value_integer)
7889 const auto x = std::strtoll(
token_buffer.data(), &endptr, 10);
7899 return token_type::value_integer;
7911 return token_type::value_float;
7924 for (std::size_t i = 1; i < length; ++i)
7929 return token_type::parse_error;
8023 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8074 if (
static_cast<unsigned char>(c) <=
'\x1F')
8077 std::array<char, 9> cs{{}};
8078 (std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c));
8079 result += cs.data();
8084 result.push_back(
static_cast<std::string::value_type
>(c));
8111 return get() == 0xBB &&
get() == 0xBF;
8134 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8135 return token_type::parse_error;
8146 return token_type::parse_error;
8157 return token_type::begin_array;
8159 return token_type::end_array;
8161 return token_type::begin_object;
8163 return token_type::end_object;
8165 return token_type::name_separator;
8167 return token_type::value_separator;
8173 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8178 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8183 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8207 case std::char_traits<char_type>::eof():
8208 return token_type::end_of_input;
8213 return token_type::parse_error;
8276 decltype(std::declval<T&>().boolean(std::declval<bool>()));
8278template<
typename T,
typename Integer>
8280 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
8282template<
typename T,
typename Un
signed>
8284 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
8286template<
typename T,
typename Float,
typename String>
8288 std::declval<Float>(), std::declval<const String&>()));
8290template<
typename T,
typename String>
8292 decltype(std::declval<T&>().string(std::declval<String&>()));
8294template<
typename T,
typename Binary>
8296 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
8300 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
8302template<
typename T,
typename String>
8304 decltype(std::declval<T&>().key(std::declval<String&>()));
8311 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
8316template<
typename T,
typename Exception>
8318 std::declval<std::size_t>(), std::declval<const std::string&>(),
8319 std::declval<const Exception&>()));
8321template<
typename SAX,
typename BasicJsonType>
8326 "BasicJsonType must be of type basic_json<...>");
8352template<
typename SAX,
typename BasicJsonType>
8357 "BasicJsonType must be of type basic_json<...>");
8368 "Missing/invalid function: bool null()");
8370 "Missing/invalid function: bool boolean(bool)");
8372 "Missing/invalid function: bool boolean(bool)");
8376 "Missing/invalid function: bool number_integer(number_integer_t)");
8380 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
8383 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
8386 "Missing/invalid function: bool string(string_t&)");
8389 "Missing/invalid function: bool binary(binary_t&)");
8391 "Missing/invalid function: bool start_object(std::size_t)");
8393 "Missing/invalid function: bool key(string_t&)");
8395 "Missing/invalid function: bool end_object()");
8397 "Missing/invalid function: bool start_array(std::size_t)");
8399 "Missing/invalid function: bool end_array()");
8402 "Missing/invalid function: bool parse_error(std::size_t, const "
8403 "std::string&, const exception&)");
8435 return *
reinterpret_cast<char*
>(&num) == 1;
8446template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
8487 const
bool strict = true,
8491 bool result =
false;
8549 std::int32_t document_size{};
8562 return sax->end_object();
8574 auto out = std::back_inserter(result);
8586 *out++ =
static_cast<typename string_t::value_type
>(
current);
8601 template<
typename NumberType>
8622 template<
typename NumberType>
8632 std::uint8_t subtype{};
8634 result.set_subtype(subtype);
8650 const std::size_t element_type_parse_position)
8652 switch (element_type)
8686 return sax->boolean(
get() != 0);
8696 std::int32_t
value{};
8702 std::int64_t
value{};
8708 std::array<char, 3> cr{{}};
8709 (std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type));
8710 return sax->parse_error(element_type_parse_position, std::string(cr.data()),
parse_error::create(114, element_type_parse_position,
"Unsupported BSON record type 0x" + std::string(cr.data()), BasicJsonType()));
8731 while (
auto element_type =
get())
8738 const std::size_t element_type_parse_position =
chars_read;
8744 if (!is_array && !
sax->key(
key))
8767 std::int32_t document_size{};
8780 return sax->end_array();
8801 case std::char_traits<char_type>::eof():
8833 std::uint8_t number{};
8839 std::uint16_t number{};
8845 std::uint32_t number{};
8851 std::uint64_t number{};
8880 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 -
current));
8884 std::uint8_t number{};
8890 std::uint16_t number{};
8896 std::uint32_t number{};
8902 std::uint64_t number{};
9002 return get_cbor_array(
static_cast<std::size_t
>(
static_cast<unsigned int>(
current) & 0x1Fu), tag_handler);
9012 std::uint16_t len{};
9018 std::uint32_t len{};
9024 std::uint64_t len{};
9056 return get_cbor_object(
static_cast<std::size_t
>(
static_cast<unsigned int>(
current) & 0x1Fu), tag_handler);
9066 std::uint16_t len{};
9072 std::uint32_t len{};
9078 std::uint64_t len{};
9105 switch (tag_handler)
9120 std::uint8_t subtype_to_ignore{};
9126 std::uint16_t subtype_to_ignore{};
9132 std::uint32_t subtype_to_ignore{};
9138 std::uint64_t subtype_to_ignore{};
9156 std::uint8_t subtype{};
9158 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9163 std::uint16_t subtype{};
9165 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9170 std::uint32_t subtype{};
9172 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9177 std::uint64_t subtype{};
9179 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9196 return sax->boolean(
false);
9199 return sax->boolean(
true);
9206 const auto byte1_raw =
get();
9211 const auto byte2_raw =
get();
9217 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
9218 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
9228 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
9229 const double val = [&half]
9231 const int exp = (half >> 10u) & 0x1Fu;
9232 const unsigned int mant = half & 0x3FFu;
9238 return std::ldexp(mant, -24);
9241 ? std::numeric_limits<double>::infinity()
9242 : std::numeric_limits<double>::quiet_NaN();
9244 return std::ldexp(mant + 1024, exp - 25);
9247 return sax->number_float((half & 0x8000u) != 0
9329 std::uint16_t len{};
9335 std::uint32_t len{};
9341 std::uint64_t len{};
9347 while (
get() != 0xFF)
9354 result.append(chunk);
9425 std::uint16_t len{};
9432 std::uint32_t len{};
9439 std::uint64_t len{};
9446 while (
get() != 0xFF)
9453 result.insert(result.end(), chunk.begin(), chunk.end());
9480 if (len != std::size_t(-1))
9482 for (std::size_t i = 0; i < len; ++i)
9492 while (
get() != 0xFF)
9501 return sax->end_array();
9521 if (len != std::size_t(-1))
9523 for (std::size_t i = 0; i < len; ++i)
9540 while (
get() != 0xFF)
9556 return sax->end_object();
9571 case std::char_traits<char_type>::eof():
9788 return sax->boolean(
false);
9791 return sax->boolean(
true);
9823 std::uint8_t number{};
9829 std::uint16_t number{};
9835 std::uint32_t number{};
9841 std::uint64_t number{};
9847 std::int8_t number{};
9853 std::int16_t number{};
9859 std::int32_t number{};
9865 std::int64_t number{};
9871 std::uint16_t len{};
9877 std::uint32_t len{};
9883 std::uint16_t len{};
9889 std::uint32_t len{};
9926 return sax->number_integer(
static_cast<std::int8_t
>(
current));
10000 std::uint16_t len{};
10006 std::uint32_t len{};
10031 auto assign_and_return_true = [&result](std::int8_t subtype)
10033 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
10041 std::uint8_t len{};
10048 std::uint16_t len{};
10055 std::uint32_t len{};
10062 std::uint8_t len{};
10063 std::int8_t subtype{};
10067 assign_and_return_true(subtype);
10072 std::uint16_t len{};
10073 std::int8_t subtype{};
10077 assign_and_return_true(subtype);
10082 std::uint32_t len{};
10083 std::int8_t subtype{};
10087 assign_and_return_true(subtype);
10092 std::int8_t subtype{};
10095 assign_and_return_true(subtype);
10100 std::int8_t subtype{};
10103 assign_and_return_true(subtype);
10108 std::int8_t subtype{};
10111 assign_and_return_true(subtype);
10116 std::int8_t subtype{};
10119 assign_and_return_true(subtype);
10124 std::int8_t subtype{};
10127 assign_and_return_true(subtype);
10146 for (std::size_t i = 0; i < len; ++i)
10154 return sax->end_array();
10169 for (std::size_t i = 0; i < len; ++i)
10184 return sax->end_object();
10233 std::uint8_t len{};
10245 std::int16_t len{};
10251 std::int32_t len{};
10257 std::int64_t len{};
10263 return sax->parse_error(
chars_read, last_token,
parse_error::create(113,
chars_read,
exception_message(
input_format_t::ubjson,
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token,
"string"), BasicJsonType()));
10277 std::uint8_t number{};
10282 result =
static_cast<std::size_t
>(number);
10288 std::int8_t number{};
10293 result =
static_cast<std::size_t
>(number);
10299 std::int16_t number{};
10304 result =
static_cast<std::size_t
>(number);
10310 std::int32_t number{};
10315 result =
static_cast<std::size_t
>(number);
10321 std::int64_t number{};
10326 result =
static_cast<std::size_t
>(number);
10333 return sax->parse_error(
chars_read, last_token,
parse_error::create(113,
chars_read,
exception_message(
input_format_t::ubjson,
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token,
"size"), BasicJsonType()));
10350 result.first = string_t::npos;
10357 result.second =
get();
10393 case std::char_traits<char_type>::eof():
10397 return sax->boolean(
true);
10399 return sax->boolean(
false);
10402 return sax->null();
10406 std::uint8_t number{};
10412 std::int8_t number{};
10418 std::int16_t number{};
10424 std::int32_t number{};
10430 std::int64_t number{};
10464 return sax->string(s);
10492 std::pair<std::size_t, char_int_type> size_and_type;
10498 if (size_and_type.first != string_t::npos)
10505 if (size_and_type.second != 0)
10507 if (size_and_type.second !=
'N')
10509 for (std::size_t i = 0; i < size_and_type.first; ++i)
10520 for (std::size_t i = 0; i < size_and_type.first; ++i)
10546 return sax->end_array();
10554 std::pair<std::size_t, char_int_type> size_and_type;
10561 if (size_and_type.first != string_t::npos)
10568 if (size_and_type.second != 0)
10570 for (std::size_t i = 0; i < size_and_type.first; ++i)
10585 for (std::size_t i = 0; i < size_and_type.first; ++i)
10621 return sax->end_object();
10630 std::size_t size{};
10638 std::vector<char> number_vector;
10639 for (std::size_t i = 0; i < size; ++i)
10646 number_vector.push_back(
static_cast<char>(
current));
10652 const auto result_number = number_lexer.scan();
10653 const auto number_string = number_lexer.get_token_string();
10654 const auto result_remainder = number_lexer.scan();
10663 switch (result_number)
10665 case token_type::value_integer:
10666 return sax->number_integer(number_lexer.get_number_integer());
10667 case token_type::value_unsigned:
10668 return sax->number_unsigned(number_lexer.get_number_unsigned());
10669 case token_type::value_float:
10670 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
10671 case token_type::uninitialized:
10672 case token_type::literal_true:
10673 case token_type::literal_false:
10674 case token_type::literal_null:
10675 case token_type::value_string:
10676 case token_type::begin_array:
10677 case token_type::begin_object:
10678 case token_type::end_array:
10679 case token_type::end_object:
10680 case token_type::name_separator:
10681 case token_type::value_separator:
10682 case token_type::parse_error:
10683 case token_type::end_of_input:
10684 case token_type::literal_or_value:
10736 template<
typename NumberType,
bool InputIsLittleEndian = false>
10740 std::array<std::uint8_t,
sizeof(NumberType)> vec{};
10741 for (std::size_t i = 0; i <
sizeof(NumberType); ++i)
10752 vec[
sizeof(NumberType) - i - 1] =
static_cast<std::uint8_t
>(
current);
10756 vec[i] =
static_cast<std::uint8_t
>(
current);
10761 std::memcpy(&result, vec.data(),
sizeof(NumberType));
10779 template<
typename NumberType>
10781 const NumberType len,
10784 bool success =
true;
10785 for (NumberType i = 0; i < len; i++)
10793 result.push_back(
static_cast<typename string_t::value_type
>(
current));
10812 template<
typename NumberType>
10814 const NumberType len,
10817 bool success =
true;
10818 for (NumberType i = 0; i < len; i++)
10826 result.push_back(
static_cast<std::uint8_t
>(
current));
10852 std::array<char, 3> cr{{}};
10853 (std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(
current));
10854 return std::string{cr.data()};
10864 const std::string& detail,
10865 const std::string& context)
const
10867 std::string error_msg =
"syntax error while parsing ";
10872 error_msg +=
"CBOR";
10876 error_msg +=
"MessagePack";
10880 error_msg +=
"UBJSON";
10884 error_msg +=
"BSON";
10892 return error_msg +
" " + context +
": " + detail;
10923#include <functional>
10967template<
typename BasicJsonType>
10969 std::function<bool(
int ,
parse_event_t , BasicJsonType& )>;
10976template<
typename BasicJsonType,
typename InputAdapterType>
10990 const bool allow_exceptions_ =
true,
10991 const bool skip_comments =
false)
10993 ,
m_lexer(
std::move(adapter), skip_comments)
11035 if (result.is_discarded())
11061 result.assert_invariant();
11076 template<
typename SAX>
11095 template<
typename SAX>
11101 std::vector<bool> states;
11103 bool skip_to_state_evaluation =
false;
11107 if (!skip_to_state_evaluation)
11112 case token_type::begin_object:
11120 if (
get_token() == token_type::end_object)
11150 states.push_back(
false);
11157 case token_type::begin_array:
11165 if (
get_token() == token_type::end_array)
11175 states.push_back(
true);
11181 case token_type::value_float:
11200 case token_type::literal_false:
11209 case token_type::literal_null:
11218 case token_type::literal_true:
11227 case token_type::value_integer:
11236 case token_type::value_string:
11245 case token_type::value_unsigned:
11254 case token_type::parse_error:
11262 case token_type::uninitialized:
11263 case token_type::end_array:
11264 case token_type::end_object:
11265 case token_type::name_separator:
11266 case token_type::value_separator:
11267 case token_type::end_of_input:
11268 case token_type::literal_or_value:
11279 skip_to_state_evaluation =
false;
11283 if (states.empty())
11292 if (
get_token() == token_type::value_separator)
11313 skip_to_state_evaluation =
true;
11325 if (
get_token() == token_type::value_separator)
11367 skip_to_state_evaluation =
true;
11385 std::string error_msg =
"syntax error ";
11387 if (!context.empty())
11389 error_msg +=
"while parsing " + context +
" ";
11404 if (expected != token_type::uninitialized)
11494 return lhs.m_it == rhs.m_it;
11499 return lhs.m_it < rhs.m_it;
11504 auto result = *
this;
11511 return lhs.m_it - rhs.m_it;
11522 auto result = *
this;
11535 auto result = *
this;
11582#include <type_traits>
11604template<
typename IteratorType>
class iteration_proxy;
11605template<
typename IteratorType>
class iteration_proxy_value;
11623template<
typename BasicJsonType>
11638 "iter_impl only accepts (const) basic_json");
11654 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
11655 typename BasicJsonType::const_pointer,
11656 typename BasicJsonType::pointer>::type;
11659 typename std::conditional<std::is_const<BasicJsonType>::value,
11660 typename BasicJsonType::const_reference,
11661 typename BasicJsonType::reference>::type;
11678 switch (m_object->m_type)
11725 : m_object(other.m_object),
m_it(other.m_it)
11736 if (&other !=
this)
11738 m_object = other.m_object;
11750 : m_object(other.m_object),
m_it(other.m_it)
11761 m_object = other.m_object;
11771 void set_begin() noexcept
11775 switch (m_object->m_type)
11819 switch (m_object->m_type)
11858 switch (m_object->m_type)
11902 switch (m_object->m_type)
11942 auto result = *
this;
11955 switch (m_object->m_type)
11993 auto result = *
this;
12006 switch (m_object->m_type)
12042 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
12053 switch (m_object->m_type)
12078 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
12098 switch (m_object->m_type)
12125 return !other.operator < (*this);
12154 switch (m_object->m_type)
12198 auto result = *
this;
12220 auto result = *
this;
12233 switch (m_object->m_type)
12262 switch (m_object->m_type)
12296 const typename object_t::key_type&
key()
const
12361template<
typename Base>
12435 auto it = --this->base();
12442 auto it = --this->base();
12443 return it.operator * ();
12454#include <algorithm>
12473template<
typename BasicJsonType>
12524 [](
const std::string & a,
const std::string & b)
12526 return a +
"/" + detail::escape(b);
12531 operator std::string()
const
12600 return *
this /= std::to_string(array_idx);
12789 static typename BasicJsonType::size_type
array_index(
const std::string& s)
12791 using size_type =
typename BasicJsonType::size_type;
12805 std::size_t processed_chars = 0;
12806 unsigned long long res = 0;
12809 res = std::stoull(s, &processed_chars);
12824 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
12829 return static_cast<size_type
>(res);
12866 if (reference_token ==
"0")
12938 if (ptr->is_null())
12942 std::all_of(reference_token.begin(), reference_token.end(),
12943 [](
const unsigned char x)
12945 return std::isdigit(x);
12949 *ptr = (nums || reference_token ==
"-")
12954 switch (ptr->type())
12959 ptr = &ptr->operator[](reference_token);
12965 if (reference_token ==
"-")
12968 ptr = &ptr->operator[](ptr->m_value.array->size());
12973 ptr = &ptr->operator[](
array_index(reference_token));
13004 switch (ptr->type())
13009 ptr = &ptr->at(reference_token);
13019 "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
13020 ") is out of range", *ptr));
13061 switch (ptr->type())
13066 ptr = &ptr->operator[](reference_token);
13079 ptr = &ptr->operator[](
array_index(reference_token));
13109 switch (ptr->type())
13114 ptr = &ptr->at(reference_token);
13124 "array index '-' (" + std::to_string(ptr->m_value.array->size()) +
13125 ") is out of range", *ptr));
13157 switch (ptr->type())
13161 if (!ptr->contains(reference_token))
13167 ptr = &ptr->operator[](reference_token);
13178 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
13190 for (std::size_t i = 1; i < reference_token.size(); i++)
13201 if (idx >= ptr->size())
13207 ptr = &ptr->operator[](idx);
13241 static std::vector<std::string>
split(
const std::string& reference_string)
13243 std::vector<std::string>
result;
13246 if (reference_string.empty())
13262 std::size_t slash = reference_string.find_first_of(
'/', 1),
13269 start = (slash == std::string::npos) ? 0 : slash + 1,
13271 slash = reference_string.find_first_of(
'/', start))
13275 auto reference_token = reference_string.substr(start, slash - start);
13278 for (std::size_t pos = reference_token.find_first_of(
'~');
13279 pos != std::string::npos;
13280 pos = reference_token.find_first_of(
'~', pos + 1))
13286 (reference_token[pos + 1] !=
'0' &&
13287 reference_token[pos + 1] !=
'1')))
13309 static void flatten(
const std::string& reference_string,
13313 switch (value.type())
13317 if (value.m_value.array->empty())
13320 result[reference_string] =
nullptr;
13325 for (std::size_t i = 0; i < value.m_value.array->size(); ++i)
13327 flatten(reference_string +
"/" + std::to_string(i),
13328 value.m_value.array->operator[](i),
result);
13336 if (value.m_value.object->empty())
13339 result[reference_string] =
nullptr;
13344 for (
const auto& element : *value.m_value.object)
13363 result[reference_string] = value;
13390 for (
const auto& element : *value.m_value.object)
13421 return lhs.reference_tokens == rhs.reference_tokens;
13438 return !(lhs == rhs);
13449#include <initializer_list>
13459template<
typename BasicJsonType>
13528#include <algorithm>
13544#include <algorithm>
13578template<typename CharType>
13582template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
13596 void write_characters(const CharType* s,
std::
size_t length)
override
13598 std::copy(s, s + length, std::back_inserter(v));
13602 std::vector<CharType, AllocatorType>&
v;
13607template<
typename CharType>
13621 void write_characters(const CharType* s,
std::
size_t length)
override
13623 stream.write(s,
static_cast<std::streamsize
>(length));
13632template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
13646 void write_characters(const CharType* s,
std::
size_t length)
override
13648 str.append(s, length);
13655template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
13659 template<
typename AllocatorType = std::allocator<CharType>>
13694template<
typename BasicJsonType,
typename CharType>
13720 case value_t::object:
13722 write_bson_object(*j.m_value.object);
13726 case value_t::null:
13727 case value_t::array:
13728 case value_t::string:
13729 case value_t::boolean:
13730 case value_t::number_integer:
13731 case value_t::number_unsigned:
13732 case value_t::number_float:
13733 case value_t::binary:
13734 case value_t::discarded:
13737 JSON_THROW(type_error::create(317,
"to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name()), j));
13749 case value_t::null:
13751 oa->write_character(to_char_type(0xF6));
13755 case value_t::boolean:
13757 oa->write_character(j.m_value.boolean
13758 ? to_char_type(0xF5)
13759 : to_char_type(0xF4));
13763 case value_t::number_integer:
13765 if (j.m_value.number_integer >= 0)
13770 if (j.m_value.number_integer <= 0x17)
13772 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13774 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
13776 oa->write_character(to_char_type(0x18));
13777 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
13779 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
13781 oa->write_character(to_char_type(0x19));
13782 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
13784 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
13786 oa->write_character(to_char_type(0x1A));
13787 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
13791 oa->write_character(to_char_type(0x1B));
13792 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
13799 const auto positive_number = -1 - j.m_value.number_integer;
13800 if (j.m_value.number_integer >= -24)
13802 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
13804 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
13806 oa->write_character(to_char_type(0x38));
13807 write_number(
static_cast<std::uint8_t
>(positive_number));
13809 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
13811 oa->write_character(to_char_type(0x39));
13812 write_number(
static_cast<std::uint16_t
>(positive_number));
13814 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
13816 oa->write_character(to_char_type(0x3A));
13817 write_number(
static_cast<std::uint32_t
>(positive_number));
13821 oa->write_character(to_char_type(0x3B));
13822 write_number(
static_cast<std::uint64_t
>(positive_number));
13828 case value_t::number_unsigned:
13830 if (j.m_value.number_unsigned <= 0x17)
13832 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
13834 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
13836 oa->write_character(to_char_type(0x18));
13837 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
13839 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
13841 oa->write_character(to_char_type(0x19));
13842 write_number(
static_cast<std::uint16_t
>(j.m_value.number_unsigned));
13844 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
13846 oa->write_character(to_char_type(0x1A));
13847 write_number(
static_cast<std::uint32_t
>(j.m_value.number_unsigned));
13851 oa->write_character(to_char_type(0x1B));
13852 write_number(
static_cast<std::uint64_t
>(j.m_value.number_unsigned));
13857 case value_t::number_float:
13859 if (std::isnan(j.m_value.number_float))
13862 oa->write_character(to_char_type(0xF9));
13863 oa->write_character(to_char_type(0x7E));
13864 oa->write_character(to_char_type(0x00));
13866 else if (std::isinf(j.m_value.number_float))
13869 oa->write_character(to_char_type(0xf9));
13870 oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
13871 oa->write_character(to_char_type(0x00));
13880 case value_t::string:
13883 const auto N = j.m_value.string->size();
13886 write_number(
static_cast<std::uint8_t
>(0x60 + N));
13888 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13890 oa->write_character(to_char_type(0x78));
13891 write_number(
static_cast<std::uint8_t
>(N));
13893 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13895 oa->write_character(to_char_type(0x79));
13896 write_number(
static_cast<std::uint16_t
>(N));
13898 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13900 oa->write_character(to_char_type(0x7A));
13901 write_number(
static_cast<std::uint32_t
>(N));
13904 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13906 oa->write_character(to_char_type(0x7B));
13907 write_number(
static_cast<std::uint64_t
>(N));
13912 oa->write_characters(
13913 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
13914 j.m_value.string->size());
13918 case value_t::array:
13921 const auto N = j.m_value.array->size();
13924 write_number(
static_cast<std::uint8_t
>(0x80 + N));
13926 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13928 oa->write_character(to_char_type(0x98));
13929 write_number(
static_cast<std::uint8_t
>(N));
13931 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13933 oa->write_character(to_char_type(0x99));
13934 write_number(
static_cast<std::uint16_t
>(N));
13936 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
13938 oa->write_character(to_char_type(0x9A));
13939 write_number(
static_cast<std::uint32_t
>(N));
13942 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
13944 oa->write_character(to_char_type(0x9B));
13945 write_number(
static_cast<std::uint64_t
>(N));
13950 for (
const auto& el : *j.m_value.array)
13957 case value_t::binary:
13959 if (j.m_value.binary->has_subtype())
13961 if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
13963 write_number(
static_cast<std::uint8_t
>(0xd8));
13964 write_number(
static_cast<std::uint8_t
>(j.m_value.binary->subtype()));
13966 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
13968 write_number(
static_cast<std::uint8_t
>(0xd9));
13969 write_number(
static_cast<std::uint16_t
>(j.m_value.binary->subtype()));
13971 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
13973 write_number(
static_cast<std::uint8_t
>(0xda));
13974 write_number(
static_cast<std::uint32_t
>(j.m_value.binary->subtype()));
13976 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
13978 write_number(
static_cast<std::uint8_t
>(0xdb));
13979 write_number(
static_cast<std::uint64_t
>(j.m_value.binary->subtype()));
13984 const auto N = j.m_value.binary->size();
13987 write_number(
static_cast<std::uint8_t
>(0x40 + N));
13989 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
13991 oa->write_character(to_char_type(0x58));
13992 write_number(
static_cast<std::uint8_t
>(N));
13994 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
13996 oa->write_character(to_char_type(0x59));
13997 write_number(
static_cast<std::uint16_t
>(N));
13999 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14001 oa->write_character(to_char_type(0x5A));
14002 write_number(
static_cast<std::uint32_t
>(N));
14005 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14007 oa->write_character(to_char_type(0x5B));
14008 write_number(
static_cast<std::uint64_t
>(N));
14013 oa->write_characters(
14014 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
14020 case value_t::object:
14023 const auto N = j.m_value.object->size();
14026 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
14028 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14030 oa->write_character(to_char_type(0xB8));
14031 write_number(
static_cast<std::uint8_t
>(N));
14033 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14035 oa->write_character(to_char_type(0xB9));
14036 write_number(
static_cast<std::uint16_t
>(N));
14038 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14040 oa->write_character(to_char_type(0xBA));
14041 write_number(
static_cast<std::uint32_t
>(N));
14044 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
14046 oa->write_character(to_char_type(0xBB));
14047 write_number(
static_cast<std::uint64_t
>(N));
14052 for (
const auto& el : *j.m_value.object)
14054 write_cbor(el.first);
14055 write_cbor(el.second);
14060 case value_t::discarded:
14073 case value_t::null:
14075 oa->write_character(to_char_type(0xC0));
14079 case value_t::boolean:
14081 oa->write_character(j.m_value.boolean
14082 ? to_char_type(0xC3)
14083 : to_char_type(0xC2));
14087 case value_t::number_integer:
14089 if (j.m_value.number_integer >= 0)
14094 if (j.m_value.number_unsigned < 128)
14097 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14099 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
14102 oa->write_character(to_char_type(0xCC));
14103 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14105 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
14108 oa->write_character(to_char_type(0xCD));
14109 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14111 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
14114 oa->write_character(to_char_type(0xCE));
14115 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14117 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
14120 oa->write_character(to_char_type(0xCF));
14121 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
14126 if (j.m_value.number_integer >= -32)
14129 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
14131 else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
14132 j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
14135 oa->write_character(to_char_type(0xD0));
14136 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
14138 else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
14139 j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
14142 oa->write_character(to_char_type(0xD1));
14143 write_number(
static_cast<std::int16_t
>(j.m_value.number_integer));
14145 else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
14146 j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
14149 oa->write_character(to_char_type(0xD2));
14150 write_number(
static_cast<std::int32_t
>(j.m_value.number_integer));
14152 else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
14153 j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
14156 oa->write_character(to_char_type(0xD3));
14157 write_number(
static_cast<std::int64_t
>(j.m_value.number_integer));
14163 case value_t::number_unsigned:
14165 if (j.m_value.number_unsigned < 128)
14168 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14170 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
14173 oa->write_character(to_char_type(0xCC));
14174 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
14176 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
14179 oa->write_character(to_char_type(0xCD));
14180 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
14182 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
14185 oa->write_character(to_char_type(0xCE));
14186 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
14188 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
14191 oa->write_character(to_char_type(0xCF));
14192 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
14197 case value_t::number_float:
14203 case value_t::string:
14206 const auto N = j.m_value.string->size();
14210 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
14212 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
14215 oa->write_character(to_char_type(0xD9));
14216 write_number(
static_cast<std::uint8_t
>(N));
14218 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14221 oa->write_character(to_char_type(0xDA));
14222 write_number(
static_cast<std::uint16_t
>(N));
14224 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14227 oa->write_character(to_char_type(0xDB));
14228 write_number(
static_cast<std::uint32_t
>(N));
14232 oa->write_characters(
14233 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
14234 j.m_value.string->size());
14238 case value_t::array:
14241 const auto N = j.m_value.array->size();
14245 write_number(
static_cast<std::uint8_t
>(0x90 | N));
14247 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14250 oa->write_character(to_char_type(0xDC));
14251 write_number(
static_cast<std::uint16_t
>(N));
14253 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14256 oa->write_character(to_char_type(0xDD));
14257 write_number(
static_cast<std::uint32_t
>(N));
14261 for (
const auto& el : *j.m_value.array)
14268 case value_t::binary:
14272 const bool use_ext = j.m_value.binary->has_subtype();
14275 const auto N = j.m_value.binary->size();
14276 if (N <= (std::numeric_limits<std::uint8_t>::max)())
14278 std::uint8_t output_type{};
14285 output_type = 0xD4;
14288 output_type = 0xD5;
14291 output_type = 0xD6;
14294 output_type = 0xD7;
14297 output_type = 0xD8;
14300 output_type = 0xC7;
14308 output_type = 0xC4;
14312 oa->write_character(to_char_type(output_type));
14315 write_number(
static_cast<std::uint8_t
>(N));
14318 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14320 std::uint8_t output_type = use_ext
14324 oa->write_character(to_char_type(output_type));
14325 write_number(
static_cast<std::uint16_t
>(N));
14327 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14329 std::uint8_t output_type = use_ext
14333 oa->write_character(to_char_type(output_type));
14334 write_number(
static_cast<std::uint32_t
>(N));
14340 write_number(
static_cast<std::int8_t
>(j.m_value.binary->subtype()));
14344 oa->write_characters(
14345 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
14351 case value_t::object:
14354 const auto N = j.m_value.object->size();
14358 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
14360 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
14363 oa->write_character(to_char_type(0xDE));
14364 write_number(
static_cast<std::uint16_t
>(N));
14366 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
14369 oa->write_character(to_char_type(0xDF));
14370 write_number(
static_cast<std::uint32_t
>(N));
14374 for (
const auto& el : *j.m_value.object)
14376 write_msgpack(el.first);
14377 write_msgpack(el.second);
14382 case value_t::discarded:
14395 const bool use_type,
const bool add_prefix =
true)
14399 case value_t::null:
14403 oa->write_character(to_char_type(
'Z'));
14408 case value_t::boolean:
14412 oa->write_character(j.m_value.boolean
14413 ? to_char_type(
'T')
14414 : to_char_type(
'F'));
14419 case value_t::number_integer:
14421 write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix);
14425 case value_t::number_unsigned:
14427 write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix);
14431 case value_t::number_float:
14433 write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix);
14437 case value_t::string:
14441 oa->write_character(to_char_type(
'S'));
14443 write_number_with_ubjson_prefix(j.m_value.string->size(),
true);
14444 oa->write_characters(
14445 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
14446 j.m_value.string->size());
14450 case value_t::array:
14454 oa->write_character(to_char_type(
'['));
14457 bool prefix_required =
true;
14458 if (use_type && !j.m_value.array->empty())
14461 const CharType first_prefix = ubjson_prefix(j.front());
14462 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
14463 [
this, first_prefix](
const BasicJsonType & v)
14465 return ubjson_prefix(v) == first_prefix;
14470 prefix_required =
false;
14471 oa->write_character(to_char_type(
'$'));
14472 oa->write_character(first_prefix);
14478 oa->write_character(to_char_type(
'#'));
14479 write_number_with_ubjson_prefix(j.m_value.array->size(),
true);
14482 for (
const auto& el : *j.m_value.array)
14484 write_ubjson(el, use_count, use_type, prefix_required);
14489 oa->write_character(to_char_type(
']'));
14495 case value_t::binary:
14499 oa->write_character(to_char_type(
'['));
14502 if (use_type && !j.m_value.binary->empty())
14505 oa->write_character(to_char_type(
'$'));
14506 oa->write_character(
'U');
14511 oa->write_character(to_char_type(
'#'));
14512 write_number_with_ubjson_prefix(j.m_value.binary->size(),
true);
14517 oa->write_characters(
14518 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
14519 j.m_value.binary->size());
14523 for (
size_t i = 0; i < j.m_value.binary->size(); ++i)
14525 oa->write_character(to_char_type(
'U'));
14526 oa->write_character(j.m_value.binary->data()[i]);
14532 oa->write_character(to_char_type(
']'));
14538 case value_t::object:
14542 oa->write_character(to_char_type(
'{'));
14545 bool prefix_required =
true;
14546 if (use_type && !j.m_value.object->empty())
14549 const CharType first_prefix = ubjson_prefix(j.front());
14550 const bool same_prefix = std::all_of(j.begin(), j.end(),
14551 [
this, first_prefix](
const BasicJsonType & v)
14553 return ubjson_prefix(v) == first_prefix;
14558 prefix_required =
false;
14559 oa->write_character(to_char_type(
'$'));
14560 oa->write_character(first_prefix);
14566 oa->write_character(to_char_type(
'#'));
14567 write_number_with_ubjson_prefix(j.m_value.object->size(),
true);
14570 for (
const auto& el : *j.m_value.object)
14572 write_number_with_ubjson_prefix(el.first.size(),
true);
14573 oa->write_characters(
14574 reinterpret_cast<const CharType*
>(el.first.c_str()),
14576 write_ubjson(el.second, use_count, use_type, prefix_required);
14581 oa->write_character(to_char_type(
'}'));
14587 case value_t::discarded:
14604 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
14607 JSON_THROW(out_of_range::create(409,
"BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) +
")", j));
14608 static_cast<void>(j);
14611 return 1ul + name.size() + 1u;
14618 const std::uint8_t element_type)
14620 oa->write_character(to_char_type(element_type));
14621 oa->write_characters(
14622 reinterpret_cast<const CharType*
>(name.c_str()),
14632 write_bson_entry_header(name, 0x08);
14633 oa->write_character(
value ? to_char_type(0x01) : to_char_type(0x00));
14640 const double value)
14642 write_bson_entry_header(name, 0x01);
14643 write_number<double, true>(
value);
14651 return sizeof(std::int32_t) +
value.size() + 1ul;
14660 write_bson_entry_header(name, 0x02);
14662 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(
value.size() + 1ul));
14663 oa->write_characters(
14664 reinterpret_cast<const CharType*
>(
value.c_str()),
14673 write_bson_entry_header(name, 0x0A);
14681 return (std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)()
14682 ?
sizeof(std::int32_t)
14683 :
sizeof(std::int64_t);
14690 const std::int64_t value)
14692 if ((std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)())
14694 write_bson_entry_header(name, 0x10);
14695 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(
value));
14699 write_bson_entry_header(name, 0x12);
14700 write_number<std::int64_t, true>(
static_cast<std::int64_t
>(
value));
14709 return (
value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
14710 ?
sizeof(std::int32_t)
14711 :
sizeof(std::int64_t);
14718 const BasicJsonType& j)
14720 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
14722 write_bson_entry_header(name, 0x10 );
14723 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(j.m_value.number_unsigned));
14725 else if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
14727 write_bson_entry_header(name, 0x12 );
14728 write_number<std::int64_t, true>(
static_cast<std::int64_t
>(j.m_value.number_unsigned));
14732 JSON_THROW(out_of_range::create(407,
"integer number " + std::to_string(j.m_value.number_unsigned) +
" cannot be represented by BSON as it does not fit int64", j));
14740 const typename BasicJsonType::object_t& value)
14742 write_bson_entry_header(name, 0x03);
14743 write_bson_object(
value);
14751 std::size_t array_index = 0ul;
14753 const std::size_t embedded_document_size = std::accumulate(std::begin(
value), std::end(
value), std::size_t(0), [&array_index](std::size_t result,
const typename BasicJsonType::array_t::value_type & el)
14755 return result + calc_bson_element_size(std::to_string(array_index++), el);
14758 return sizeof(std::int32_t) + embedded_document_size + 1ul;
14766 return sizeof(std::int32_t) +
value.size() + 1ul;
14773 const typename BasicJsonType::array_t& value)
14775 write_bson_entry_header(name, 0x04);
14776 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(calc_bson_array_size(
value)));
14778 std::size_t array_index = 0ul;
14780 for (
const auto& el :
value)
14782 write_bson_element(std::to_string(array_index++), el);
14785 oa->write_character(to_char_type(0x00));
14794 write_bson_entry_header(name, 0x05);
14796 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(
value.size()));
14797 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) : std::uint8_t(0x00));
14799 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
14807 const BasicJsonType& j)
14809 const auto header_size = calc_bson_entry_header_size(name, j);
14812 case value_t::object:
14813 return header_size + calc_bson_object_size(*j.m_value.object);
14815 case value_t::array:
14816 return header_size + calc_bson_array_size(*j.m_value.array);
14818 case value_t::binary:
14819 return header_size + calc_bson_binary_size(*j.m_value.binary);
14821 case value_t::boolean:
14822 return header_size + 1ul;
14824 case value_t::number_float:
14825 return header_size + 8ul;
14827 case value_t::number_integer:
14828 return header_size + calc_bson_integer_size(j.m_value.number_integer);
14830 case value_t::number_unsigned:
14831 return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
14833 case value_t::string:
14834 return header_size + calc_bson_string_size(*j.m_value.string);
14836 case value_t::null:
14837 return header_size + 0ul;
14840 case value_t::discarded:
14855 const BasicJsonType& j)
14859 case value_t::object:
14860 return write_bson_object_entry(name, *j.m_value.object);
14862 case value_t::array:
14863 return write_bson_array(name, *j.m_value.array);
14865 case value_t::binary:
14866 return write_bson_binary(name, *j.m_value.binary);
14868 case value_t::boolean:
14869 return write_bson_boolean(name, j.m_value.boolean);
14871 case value_t::number_float:
14872 return write_bson_double(name, j.m_value.number_float);
14874 case value_t::number_integer:
14875 return write_bson_integer(name, j.m_value.number_integer);
14877 case value_t::number_unsigned:
14878 return write_bson_unsigned(name, j);
14880 case value_t::string:
14881 return write_bson_string(name, *j.m_value.string);
14883 case value_t::null:
14884 return write_bson_null(name);
14887 case value_t::discarded:
14903 std::size_t document_size = std::accumulate(
value.begin(),
value.end(), std::size_t(0),
14904 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
14906 return result += calc_bson_element_size(el.first, el.second);
14909 return sizeof(std::int32_t) + document_size + 1ul;
14918 write_number<std::int32_t, true>(
static_cast<std::int32_t
>(calc_bson_object_size(
value)));
14920 for (
const auto& el :
value)
14922 write_bson_element(el.first, el.second);
14925 oa->write_character(to_char_type(0x00));
14934 return to_char_type(0xFA);
14939 return to_char_type(0xFB);
14948 return to_char_type(0xCA);
14953 return to_char_type(0xCB);
14961 template<
typename NumberType,
typename std::enable_if<
14962 std::is_floating_point<NumberType>::value,
int>::type = 0>
14964 const bool add_prefix)
14968 oa->write_character(get_ubjson_float_prefix(n));
14974 template<
typename NumberType,
typename std::enable_if<
14975 std::is_unsigned<NumberType>::value,
int>::type = 0>
14977 const bool add_prefix)
14979 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
14983 oa->write_character(to_char_type(
'i'));
14985 write_number(
static_cast<std::uint8_t
>(n));
14987 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
14991 oa->write_character(to_char_type(
'U'));
14993 write_number(
static_cast<std::uint8_t
>(n));
14995 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
14999 oa->write_character(to_char_type(
'I'));
15001 write_number(
static_cast<std::int16_t
>(n));
15003 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15007 oa->write_character(to_char_type(
'l'));
15009 write_number(
static_cast<std::int32_t
>(n));
15011 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
15015 oa->write_character(to_char_type(
'L'));
15017 write_number(
static_cast<std::int64_t
>(n));
15023 oa->write_character(to_char_type(
'H'));
15026 const auto number = BasicJsonType(n).dump();
15027 write_number_with_ubjson_prefix(number.size(),
true);
15028 for (std::size_t i = 0; i < number.size(); ++i)
15030 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
15036 template <
typename NumberType,
typename std::enable_if <
15037 std::is_signed<NumberType>::value&&
15038 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
15040 const bool add_prefix)
15042 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
15046 oa->write_character(to_char_type(
'i'));
15048 write_number(
static_cast<std::int8_t
>(n));
15050 else if (
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::max)()))
15054 oa->write_character(to_char_type(
'U'));
15056 write_number(
static_cast<std::uint8_t
>(n));
15058 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
15062 oa->write_character(to_char_type(
'I'));
15064 write_number(
static_cast<std::int16_t
>(n));
15066 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
15070 oa->write_character(to_char_type(
'l'));
15072 write_number(
static_cast<std::int32_t
>(n));
15074 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
15078 oa->write_character(to_char_type(
'L'));
15080 write_number(
static_cast<std::int64_t
>(n));
15087 oa->write_character(to_char_type(
'H'));
15090 const auto number = BasicJsonType(n).dump();
15091 write_number_with_ubjson_prefix(number.size(),
true);
15092 for (std::size_t i = 0; i < number.size(); ++i)
15094 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
15107 case value_t::null:
15110 case value_t::boolean:
15111 return j.m_value.boolean ?
'T' :
'F';
15113 case value_t::number_integer:
15115 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
15119 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15123 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
15127 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
15131 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
15139 case value_t::number_unsigned:
15141 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
15145 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
15149 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
15153 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
15157 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
15165 case value_t::number_float:
15166 return get_ubjson_float_prefix(j.m_value.number_float);
15168 case value_t::string:
15171 case value_t::array:
15172 case value_t::binary:
15175 case value_t::object:
15178 case value_t::discarded:
15209 template<
typename NumberType,
bool OutputIsLittleEndian = false>
15213 std::array<CharType,
sizeof(NumberType)> vec{};
15214 std::memcpy(vec.data(), &n,
sizeof(NumberType));
15217 if (is_little_endian != OutputIsLittleEndian)
15220 std::reverse(vec.begin(), vec.end());
15223 oa->write_characters(vec.data(),
sizeof(NumberType));
15229#pragma GCC diagnostic push
15230#pragma GCC diagnostic ignored "-Wfloat-equal"
15232 if (
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
15233 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
15234 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))
15237 ? get_cbor_float_prefix(
static_cast<float>(n))
15238 : get_msgpack_float_prefix(
static_cast<float>(n)));
15239 write_number(
static_cast<float>(n));
15244 ? get_cbor_float_prefix(n)
15245 : get_msgpack_float_prefix(n));
15249#pragma GCC diagnostic pop
15258 template <
typename C = CharType,
15259 enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * =
nullptr >
15262 return *
reinterpret_cast<char*
>(&x);
15265 template <
typename C = CharType,
15266 enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * =
nullptr >
15269 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
15270 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
15272 std::memcpy(&result, &x,
sizeof(x));
15276 template<
typename C = CharType,
15283 template <
typename InputCharType,
typename C = CharType,
15285 std::is_signed<C>::value &&
15286 std::is_signed<char>::value &&
15287 std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
15309#include <algorithm>
15320#include <type_traits>
15331#include <type_traits>
15363template<
typename Target,
typename Source>
15366 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
15369 std::memcpy(&target, &source,
sizeof(Source));
15380 constexpr diyfp(std::uint64_t f_,
int e_) noexcept :
f(f_),
e(e_) {}
15391 return {x.f - y.f, x.e};
15400 static_assert(
kPrecision == 64,
"internal error");
15425 const std::uint64_t u_lo = x.
f & 0xFFFFFFFFu;
15426 const std::uint64_t u_hi = x.f >> 32u;
15427 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
15428 const std::uint64_t v_hi = y.f >> 32u;
15430 const std::uint64_t p0 = u_lo * v_lo;
15431 const std::uint64_t p1 = u_lo * v_hi;
15432 const std::uint64_t p2 = u_hi * v_lo;
15433 const std::uint64_t p3 = u_hi * v_hi;
15435 const std::uint64_t p0_hi = p0 >> 32u;
15436 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
15437 const std::uint64_t p1_hi = p1 >> 32u;
15438 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
15439 const std::uint64_t p2_hi = p2 >> 32u;
15441 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
15452 Q += std::uint64_t{1} << (64u - 32u - 1u);
15454 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
15456 return {h, x.e + y.e + 64};
15467 while ((x.f >> 63u) == 0)
15482 const int delta = x.
e - target_exponent;
15487 return {x.f << delta, target_exponent};
15504template<
typename FloatType>
15517 static_assert(std::numeric_limits<FloatType>::is_iec559,
15518 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
15520 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
15521 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
15522 constexpr int kMinExp = 1 - kBias;
15523 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
15525 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
15527 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(
value));
15528 const std::uint64_t E = bits >> (kPrecision - 1);
15529 const std::uint64_t F = bits & (kHiddenBit - 1);
15531 const bool is_denormal = E == 0;
15532 const diyfp v = is_denormal
15533 ?
diyfp(F, kMinExp)
15534 :
diyfp(F + kHiddenBit,
static_cast<int>(E) - kBias);
15557 const bool lower_boundary_is_closer = F == 0 && E > 1;
15559 const diyfp m_minus = lower_boundary_is_closer
15560 ?
diyfp(4 * v.
f - 1, v.
e - 2)
15561 :
diyfp(2 * v.
f - 1, v.
e - 1);
15696 constexpr int kCachedPowersMinDecExp = -300;
15697 constexpr int kCachedPowersDecStep = 8;
15699 static constexpr std::array<cached_power, 79> kCachedPowers =
15702 { 0xAB70FE17C79AC6CA, -1060, -300 },
15703 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
15704 { 0xBE5691EF416BD60C, -1007, -284 },
15705 { 0x8DD01FAD907FFC3C, -980, -276 },
15706 { 0xD3515C2831559A83, -954, -268 },
15707 { 0x9D71AC8FADA6C9B5, -927, -260 },
15708 { 0xEA9C227723EE8BCB, -901, -252 },
15709 { 0xAECC49914078536D, -874, -244 },
15710 { 0x823C12795DB6CE57, -847, -236 },
15711 { 0xC21094364DFB5637, -821, -228 },
15712 { 0x9096EA6F3848984F, -794, -220 },
15713 { 0xD77485CB25823AC7, -768, -212 },
15714 { 0xA086CFCD97BF97F4, -741, -204 },
15715 { 0xEF340A98172AACE5, -715, -196 },
15716 { 0xB23867FB2A35B28E, -688, -188 },
15717 { 0x84C8D4DFD2C63F3B, -661, -180 },
15718 { 0xC5DD44271AD3CDBA, -635, -172 },
15719 { 0x936B9FCEBB25C996, -608, -164 },
15720 { 0xDBAC6C247D62A584, -582, -156 },
15721 { 0xA3AB66580D5FDAF6, -555, -148 },
15722 { 0xF3E2F893DEC3F126, -529, -140 },
15723 { 0xB5B5ADA8AAFF80B8, -502, -132 },
15724 { 0x87625F056C7C4A8B, -475, -124 },
15725 { 0xC9BCFF6034C13053, -449, -116 },
15726 { 0x964E858C91BA2655, -422, -108 },
15727 { 0xDFF9772470297EBD, -396, -100 },
15728 { 0xA6DFBD9FB8E5B88F, -369, -92 },
15729 { 0xF8A95FCF88747D94, -343, -84 },
15730 { 0xB94470938FA89BCF, -316, -76 },
15731 { 0x8A08F0F8BF0F156B, -289, -68 },
15732 { 0xCDB02555653131B6, -263, -60 },
15733 { 0x993FE2C6D07B7FAC, -236, -52 },
15734 { 0xE45C10C42A2B3B06, -210, -44 },
15735 { 0xAA242499697392D3, -183, -36 },
15736 { 0xFD87B5F28300CA0E, -157, -28 },
15737 { 0xBCE5086492111AEB, -130, -20 },
15738 { 0x8CBCCC096F5088CC, -103, -12 },
15739 { 0xD1B71758E219652C, -77, -4 },
15740 { 0x9C40000000000000, -50, 4 },
15741 { 0xE8D4A51000000000, -24, 12 },
15742 { 0xAD78EBC5AC620000, 3, 20 },
15743 { 0x813F3978F8940984, 30, 28 },
15744 { 0xC097CE7BC90715B3, 56, 36 },
15745 { 0x8F7E32CE7BEA5C70, 83, 44 },
15746 { 0xD5D238A4ABE98068, 109, 52 },
15747 { 0x9F4F2726179A2245, 136, 60 },
15748 { 0xED63A231D4C4FB27, 162, 68 },
15749 { 0xB0DE65388CC8ADA8, 189, 76 },
15750 { 0x83C7088E1AAB65DB, 216, 84 },
15751 { 0xC45D1DF942711D9A, 242, 92 },
15752 { 0x924D692CA61BE758, 269, 100 },
15753 { 0xDA01EE641A708DEA, 295, 108 },
15754 { 0xA26DA3999AEF774A, 322, 116 },
15755 { 0xF209787BB47D6B85, 348, 124 },
15756 { 0xB454E4A179DD1877, 375, 132 },
15757 { 0x865B86925B9BC5C2, 402, 140 },
15758 { 0xC83553C5C8965D3D, 428, 148 },
15759 { 0x952AB45CFA97A0B3, 455, 156 },
15760 { 0xDE469FBD99A05FE3, 481, 164 },
15761 { 0xA59BC234DB398C25, 508, 172 },
15762 { 0xF6C69A72A3989F5C, 534, 180 },
15763 { 0xB7DCBF5354E9BECE, 561, 188 },
15764 { 0x88FCF317F22241E2, 588, 196 },
15765 { 0xCC20CE9BD35C78A5, 614, 204 },
15766 { 0x98165AF37B2153DF, 641, 212 },
15767 { 0xE2A0B5DC971F303A, 667, 220 },
15768 { 0xA8D9D1535CE3B396, 694, 228 },
15769 { 0xFB9B7CD9A4A7443C, 720, 236 },
15770 { 0xBB764C4CA7A44410, 747, 244 },
15771 { 0x8BAB8EEFB6409C1A, 774, 252 },
15772 { 0xD01FEF10A657842C, 800, 260 },
15773 { 0x9B10A4E5E9913129, 827, 268 },
15774 { 0xE7109BFBA19C0C9D, 853, 276 },
15775 { 0xAC2820D9623BF429, 880, 284 },
15776 { 0x80444B5E7AA7CF85, 907, 292 },
15777 { 0xBF21E44003ACDD2D, 933, 300 },
15778 { 0x8E679C2F5E44FF8F, 960, 308 },
15779 { 0xD433179D9C8CB841, 986, 316 },
15780 { 0x9E19DB92B4E31BA9, 1013, 324 },
15790 const int f =
kAlpha - e - 1;
15791 const int k = (f * 78913) / (1 << 18) +
static_cast<int>(f > 0);
15793 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
15795 JSON_ASSERT(
static_cast<std::size_t
>(index) < kCachedPowers.size());
15797 const cached_power cached = kCachedPowers[
static_cast<std::size_t
>(index)];
15811 if (n >= 1000000000)
15813 pow10 = 1000000000;
15817 if (n >= 100000000)
15862inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
15863 std::uint64_t rest, std::uint64_t ten_k)
15890 && delta - rest >= ten_k
15891 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
15906 static_assert(
kAlpha >= -60,
"internal error");
15907 static_assert(
kGamma <= -32,
"internal error");
15924 std::uint64_t delta =
diyfp::sub(M_plus, M_minus).
f;
15934 const diyfp one(std::uint64_t{1} << -M_plus.
e, M_plus.
e);
15936 auto p1 =
static_cast<std::uint32_t
>(M_plus.
f >> -one.e);
15937 std::uint64_t p2 = M_plus.
f & (one.f - 1);
15945 std::uint32_t pow10{};
15973 const std::uint32_t d = p1 / pow10;
15974 const std::uint32_t r = p1 % pow10;
15980 buffer[length++] =
static_cast<char>(
'0' + d);
15999 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
16004 decimal_exponent += n;
16015 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
16016 grisu2_round(buffer, length, dist, delta, rest, ten_n);
16077 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
16079 const std::uint64_t d = p2 >> -one.e;
16080 const std::uint64_t r = p2 & (one.f - 1);
16087 buffer[length++] =
static_cast<char>(
'0' + d);
16112 decimal_exponent -= m;
16120 const std::uint64_t ten_m = one.f;
16144inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
16161 const diyfp c_minus_k(cached.
f, cached.
e);
16189 const diyfp M_minus(w_minus.
f + 1, w_minus.
e);
16190 const diyfp M_plus (w_plus.
f - 1, w_plus.
e );
16192 decimal_exponent = -cached.
k;
16202template<
typename FloatType>
16207 "internal error: not enough precision");
16259 auto k =
static_cast<std::uint32_t
>(e);
16265 *buf++ =
static_cast<char>(
'0' + k);
16269 *buf++ =
static_cast<char>(
'0' + k / 10);
16271 *buf++ =
static_cast<char>(
'0' + k);
16275 *buf++ =
static_cast<char>(
'0' + k / 100);
16277 *buf++ =
static_cast<char>(
'0' + k / 10);
16279 *buf++ =
static_cast<char>(
'0' + k);
16297 int min_exp,
int max_exp)
16303 const int n = len + decimal_exponent;
16309 if (k <= n && n <= max_exp)
16314 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
16318 return buf + (
static_cast<size_t>(n) + 2);
16321 if (0 < n && n <= max_exp)
16328 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
16330 return buf + (
static_cast<size_t>(k) + 1U);
16333 if (min_exp < n && n <= 0)
16338 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
16341 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
16342 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
16357 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
16359 buf += 1 +
static_cast<size_t>(k);
16378template<
typename FloatType>
16383 static_cast<void>(last);
16387 if (std::signbit(
value))
16394#pragma GCC diagnostic push
16395#pragma GCC diagnostic ignored "-Wfloat-equal"
16406#pragma GCC diagnostic pop
16409 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
16416 int decimal_exponent = 0;
16419 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
16422 constexpr int kMinExp = -4;
16424 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
16427 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
16428 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
16465template<
typename BasicJsonType>
16485 ,
loc(
std::localeconv())
16523 const bool pretty_print,
16525 const unsigned int indent_step,
16526 const unsigned int current_indent = 0)
16528 switch (val.m_type)
16532 if (val.m_value.object->empty())
16534 o->write_characters(
"{}", 2);
16540 o->write_characters(
"{\n", 2);
16543 const auto new_indent = current_indent + indent_step;
16550 auto i = val.m_value.object->cbegin();
16551 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
16554 o->write_character(
'\"');
16556 o->write_characters(
"\": ", 3);
16558 o->write_characters(
",\n", 2);
16563 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
16565 o->write_character(
'\"');
16567 o->write_characters(
"\": ", 3);
16570 o->write_character(
'\n');
16571 o->write_characters(
indent_string.c_str(), current_indent);
16572 o->write_character(
'}');
16576 o->write_character(
'{');
16579 auto i = val.m_value.object->cbegin();
16580 for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
16582 o->write_character(
'\"');
16584 o->write_characters(
"\":", 2);
16586 o->write_character(
',');
16591 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
16592 o->write_character(
'\"');
16594 o->write_characters(
"\":", 2);
16597 o->write_character(
'}');
16605 if (val.m_value.array->empty())
16607 o->write_characters(
"[]", 2);
16613 o->write_characters(
"[\n", 2);
16616 const auto new_indent = current_indent + indent_step;
16623 for (
auto i = val.m_value.array->cbegin();
16624 i != val.m_value.array->cend() - 1; ++i)
16628 o->write_characters(
",\n", 2);
16634 dump(val.m_value.array->back(),
true,
ensure_ascii, indent_step, new_indent);
16636 o->write_character(
'\n');
16637 o->write_characters(
indent_string.c_str(), current_indent);
16638 o->write_character(
']');
16642 o->write_character(
'[');
16645 for (
auto i = val.m_value.array->cbegin();
16646 i != val.m_value.array->cend() - 1; ++i)
16649 o->write_character(
',');
16654 dump(val.m_value.array->back(),
false,
ensure_ascii, indent_step, current_indent);
16656 o->write_character(
']');
16664 o->write_character(
'\"');
16666 o->write_character(
'\"');
16674 o->write_characters(
"{\n", 2);
16677 const auto new_indent = current_indent + indent_step;
16685 o->write_characters(
"\"bytes\": [", 10);
16687 if (!val.m_value.binary->empty())
16689 for (
auto i = val.m_value.binary->cbegin();
16690 i != val.m_value.binary->cend() - 1; ++i)
16693 o->write_characters(
", ", 2);
16695 dump_integer(val.m_value.binary->back());
16698 o->write_characters(
"],\n", 3);
16701 o->write_characters(
"\"subtype\": ", 11);
16702 if (val.m_value.binary->has_subtype())
16704 dump_integer(val.m_value.binary->subtype());
16708 o->write_characters(
"null", 4);
16710 o->write_character(
'\n');
16711 o->write_characters(
indent_string.c_str(), current_indent);
16712 o->write_character(
'}');
16716 o->write_characters(
"{\"bytes\":[", 10);
16718 if (!val.m_value.binary->empty())
16720 for (
auto i = val.m_value.binary->cbegin();
16721 i != val.m_value.binary->cend() - 1; ++i)
16724 o->write_character(
',');
16726 dump_integer(val.m_value.binary->back());
16729 o->write_characters(
"],\"subtype\":", 12);
16730 if (val.m_value.binary->has_subtype())
16732 dump_integer(val.m_value.binary->subtype());
16733 o->write_character(
'}');
16737 o->write_characters(
"null}", 5);
16745 if (val.m_value.boolean)
16747 o->write_characters(
"true", 4);
16751 o->write_characters(
"false", 5);
16758 dump_integer(val.m_value.number_integer);
16764 dump_integer(val.m_value.number_unsigned);
16770 dump_float(val.m_value.number_float);
16776 o->write_characters(
"<discarded>", 11);
16782 o->write_characters(
"null", 4);
16808 std::uint32_t codepoint{};
16816 for (std::size_t i = 0; i < s.size(); ++i)
16818 const auto byte =
static_cast<std::uint8_t
>(s[i]);
16820 switch (decode(
state, codepoint,
byte))
16879 if ((codepoint <= 0x1F) || (
ensure_ascii && (codepoint >= 0x7F)))
16881 if (codepoint <= 0xFFFF)
16885 static_cast<std::uint16_t
>(codepoint));
16892 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
16893 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu)));
16928 std::stringstream ss;
16929 ss << std::uppercase << std::setfill(
'0') << std::setw(2) << std::hex << (
byte | 0);
17022 std::stringstream ss;
17023 ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << (static_cast<std::uint8_t>(s.back()) | 0);
17041 o->write_characters(
"\\ufffd", 6);
17045 o->write_characters(
"\xEF\xBF\xBD", 3);
17067 unsigned int n_digits = 1;
17076 return n_digits + 1;
17080 return n_digits + 2;
17084 return n_digits + 3;
17101 std::is_integral<NumberType>::value ||
17102 std::is_same<NumberType, number_unsigned_t>::value ||
17103 std::is_same<NumberType, number_integer_t>::value ||
17104 std::is_same<NumberType, binary_char_t>::value,
17106 void dump_integer(NumberType x)
17108 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
17111 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
17112 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
17113 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
17114 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
17115 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
17116 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
17117 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
17118 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
17119 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
17120 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
17127 o->write_character(
'0');
17134 const bool is_negative = std::is_signed<NumberType>::value && !(x >= 0);
17137 unsigned int n_chars{};
17145 n_chars = 1 + count_digits(abs_value);
17150 n_chars = count_digits(abs_value);
17158 buffer_ptr += n_chars;
17162 while (abs_value >= 100)
17164 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
17166 *(--buffer_ptr) = digits_to_99[digits_index][1];
17167 *(--buffer_ptr) = digits_to_99[digits_index][0];
17170 if (abs_value >= 10)
17172 const auto digits_index =
static_cast<unsigned>(abs_value);
17173 *(--buffer_ptr) = digits_to_99[digits_index][1];
17174 *(--buffer_ptr) = digits_to_99[digits_index][0];
17178 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
17195 if (!std::isfinite(x))
17197 o->write_characters(
"null", 4);
17206 static constexpr bool is_ieee_single_or_double
17207 = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) ||
17208 (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024);
17210 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
17218 o->write_characters(begin,
static_cast<size_t>(end - begin));
17224 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
17256 o->write_characters(
number_buffer.data(),
static_cast<std::size_t
>(len));
17259 const bool value_is_int_like =
17263 return c ==
'.' || c ==
'e';
17266 if (value_is_int_like)
17268 o->write_characters(
".0", 2);
17293 static std::uint8_t decode(std::uint8_t&
state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
17295 static const std::array<std::uint8_t, 400> utf8d =
17298 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17299 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17300 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17301 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17302 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
17303 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
17304 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
17305 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
17306 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
17307 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
17308 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,
17309 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
17310 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
17311 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
17316 const std::uint8_t type = utf8d[byte];
17319 ? (
byte & 0x3fu) | (codep << 6u)
17320 : (0xFFu >> type) & (byte);
17322 std::size_t index = 256u +
static_cast<size_t>(
state) * 16u +
static_cast<size_t>(type);
17324 state = utf8d[index];
17350 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
17356 output_adapter_t<char> o =
nullptr;
17389#include <functional>
17390#include <initializer_list>
17393#include <stdexcept>
17394#include <type_traits>
17406template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
17407 class Allocator = std::allocator<std::pair<const Key, T>>>
17412 using Container = std::vector<std::pair<const Key, T>, Allocator>;
17413 using typename Container::iterator;
17414 using typename Container::const_iterator;
17415 using typename Container::size_type;
17416 using typename Container::value_type;
17421 template <
class It>
17424 ordered_map(std::initializer_list<T> init,
const Allocator& alloc = Allocator() )
17429 for (
auto it = this->begin(); it != this->end(); ++it)
17431 if (it->first == key)
17433 return {it,
false};
17436 Container::emplace_back(key, t);
17437 return {--this->end(),
true};
17442 return emplace(key, T{}).first->second;
17452 for (
auto it = this->begin(); it != this->end(); ++it)
17454 if (it->first == key)
17460 JSON_THROW(std::out_of_range(
"key not found"));
17463 const T&
at(
const Key& key)
const
17465 for (
auto it = this->begin(); it != this->end(); ++it)
17467 if (it->first == key)
17473 JSON_THROW(std::out_of_range(
"key not found"));
17478 for (
auto it = this->begin(); it != this->end(); ++it)
17480 if (it->first == key)
17483 for (
auto next = it; ++next != this->end(); ++it)
17486 new (&*it) value_type{std::move(*next)};
17488 Container::pop_back();
17497 return erase(pos, std::next(pos));
17500 iterator
erase(iterator first, iterator last)
17502 const auto elements_affected = std::distance(first, last);
17503 const auto offset = std::distance(Container::begin(), first);
17525 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
17528 new (&*it) value_type{std::move(*std::next(it, elements_affected))};
17536 Container::resize(this->size() -
static_cast<size_type
>(elements_affected));
17545 return Container::begin() + offset;
17550 for (
auto it = this->begin(); it != this->end(); ++it)
17552 if (it->first == key)
17562 for (
auto it = this->begin(); it != this->end(); ++it)
17564 if (it->first == key)
17569 return Container::end();
17572 const_iterator
find(
const Key& key)
const
17574 for (
auto it = this->begin(); it != this->end(); ++it)
17576 if (it->first == key)
17581 return Container::end();
17584 std::pair<iterator, bool>
insert( value_type&& value )
17586 return emplace(value.first, std::move(value.second));
17589 std::pair<iterator, bool>
insert(
const value_type& value )
17591 for (
auto it = this->begin(); it != this->end(); ++it)
17593 if (it->first == value.first)
17595 return {it,
false};
17598 Container::push_back(value);
17599 return {--this->end(),
true};
17602 template<
typename InputIt>
17603 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
17604 std::input_iterator_tag>::value>::type;
17606 template<
typename InputIt,
typename = require_input_iter<InputIt>>
17609 for (
auto it = first; it != last; ++it)
17619#if defined(JSON_HAS_CPP_17)
17620 #include <string_view>
17720 friend ::nlohmann::json_pointer<basic_json>;
17722 template<
typename BasicJsonType,
typename InputType>
17723 friend class ::nlohmann::detail::parser;
17724 friend ::nlohmann::detail::serializer<basic_json>;
17725 template<
typename BasicJsonType>
17726 friend class ::nlohmann::detail::iter_impl;
17727 template<
typename BasicJsonType,
typename CharType>
17728 friend class ::nlohmann::detail::binary_writer;
17729 template<
typename BasicJsonType,
typename InputType,
typename SAX>
17730 friend class ::nlohmann::detail::binary_reader;
17731 template<
typename BasicJsonType>
17732 friend class ::nlohmann::detail::json_sax_dom_parser;
17733 template<
typename BasicJsonType>
17734 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
17735 friend class ::nlohmann::detail::exception;
17744 template<
typename InputAdapterType>
17745 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
17746 InputAdapterType adapter,
17748 const bool allow_exceptions =
true,
17749 const bool ignore_comments =
false
17752 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
17753 std::move(cb), allow_exceptions, ignore_comments);
17758 template<
typename BasicJsonType>
17760 template<
typename BasicJsonType>
17762 template<
typename Iterator>
17766 template<
typename CharType>
17769 template<
typename InputType>
17780 template<
typename T,
typename SFINAE>
17843 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
17845 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
17898 result[
"copyright"] =
"(C) 2013-2021 Niels Lohmann";
17899 result[
"name"] =
"JSON for Modern C++";
17900 result[
"url"] =
"https://github.com/nlohmann/json";
17901 result[
"version"][
"string"] =
17910 result[
"platform"] =
"win32";
17911#elif defined __linux__
17912 result[
"platform"] =
"linux";
17913#elif defined __APPLE__
17914 result[
"platform"] =
"apple";
17915#elif defined __unix__
17916 result[
"platform"] =
"unix";
17918 result[
"platform"] =
"unknown";
17921#if defined(__ICC) || defined(__INTEL_COMPILER)
17922 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
17923#elif defined(__clang__)
17924 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
17925#elif defined(__GNUC__) || defined(__GNUG__)
17926 result[
"compiler"] = {{
"family",
"gcc"}, {
"version", std::to_string(__GNUC__) +
"." + std::to_string(__GNUC_MINOR__) +
"." + std::to_string(__GNUC_PATCHLEVEL__)}};
17927#elif defined(__HP_cc) || defined(__HP_aCC)
17928 result[
"compiler"] =
"hp"
17929#elif defined(__IBMCPP__)
17930 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
17931#elif defined(_MSC_VER)
17932 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
17933#elif defined(__PGI)
17934 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
17935#elif defined(__SUNPRO_CC)
17936 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
17938 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
17942 result[
"compiler"][
"c++"] = std::to_string(__cplusplus);
17944 result[
"compiler"][
"c++"] =
"unknown";
17959#if defined(JSON_HAS_CPP_14)
18053 AllocatorType<std::pair<
const StringType,
18100 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
18467 template<
typename T,
typename... Args>
18471 AllocatorType<T> alloc;
18472 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
18474 auto deleter = [&](T * obj)
18476 AllocatorTraits::deallocate(alloc, obj, 1);
18478 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
18479 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
18481 return obj.release();
18548 case value_t::object:
18550 object = create<object_t>();
18554 case value_t::array:
18556 array = create<array_t>();
18560 case value_t::string:
18562 string = create<string_t>(
"");
18566 case value_t::binary:
18568 binary = create<binary_t>();
18572 case value_t::boolean:
18578 case value_t::number_integer:
18584 case value_t::number_unsigned:
18590 case value_t::number_float:
18596 case value_t::null:
18602 case value_t::discarded:
18647 if (t == value_t::array || t == value_t::object)
18650 std::vector<basic_json> stack;
18653 if (t == value_t::array)
18655 stack.reserve(
array->size());
18656 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
18661 for (
auto&& it : *
object)
18663 stack.push_back(std::move(it.second));
18667 while (!stack.empty())
18670 basic_json current_item(std::move(stack.back()));
18677 std::move(current_item.
m_value.array->begin(), current_item.
m_value.array->end(), std::back_inserter(stack));
18679 current_item.
m_value.array->clear();
18683 for (
auto&& it : *current_item.
m_value.object)
18685 stack.push_back(std::move(it.second));
18688 current_item.
m_value.object->clear();
18698 case value_t::object:
18700 AllocatorType<object_t> alloc;
18701 std::allocator_traits<
decltype(alloc)>
::destroy(alloc,
object);
18702 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
18706 case value_t::array:
18708 AllocatorType<array_t> alloc;
18710 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
array, 1);
18714 case value_t::string:
18716 AllocatorType<string_t> alloc;
18717 std::allocator_traits<
decltype(alloc)>
::destroy(alloc,
string);
18718 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
18722 case value_t::binary:
18724 AllocatorType<binary_t> alloc;
18726 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
binary, 1);
18730 case value_t::null:
18731 case value_t::boolean:
18732 case value_t::number_integer:
18733 case value_t::number_unsigned:
18734 case value_t::number_float:
18735 case value_t::discarded:
18770#if JSON_DIAGNOSTICS
18776 return j.m_parent ==
this;
18781 static_cast<void>(check_parents);
18786#if JSON_DIAGNOSTICS
18789 case value_t::array:
18791 for (
auto& element : *
m_value.array)
18793 element.m_parent =
this;
18798 case value_t::object:
18800 for (
auto& element : *
m_value.object)
18802 element.second.m_parent =
this;
18807 case value_t::null:
18808 case value_t::string:
18809 case value_t::boolean:
18810 case value_t::number_integer:
18811 case value_t::number_unsigned:
18812 case value_t::number_float:
18813 case value_t::binary:
18814 case value_t::discarded:
18823#if JSON_DIAGNOSTICS
18826 (it + i)->m_parent =
this;
18829 static_cast<void>(count_set_parents);
18836#if JSON_DIAGNOSTICS
18837 if (old_capacity != std::size_t(-1))
18851#ifdef JSON_HEDLEY_MSVC_VERSION
18852#pragma warning(push )
18853#pragma warning(disable : 4127)
18860#ifdef JSON_HEDLEY_MSVC_VERSION
18861#pragma warning( pop )
18866 static_cast<void>(j);
18867 static_cast<void>(old_capacity);
19076 template <
typename CompatibleType,
19081 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
19082 std::forward<CompatibleType>(val))))
19084 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
19115 template <
typename BasicJsonType,
19120 using other_boolean_t =
typename BasicJsonType::boolean_t;
19121 using other_number_float_t =
typename BasicJsonType::number_float_t;
19122 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
19123 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
19124 using other_string_t =
typename BasicJsonType::string_t;
19125 using other_object_t =
typename BasicJsonType::object_t;
19126 using other_array_t =
typename BasicJsonType::array_t;
19127 using other_binary_t =
typename BasicJsonType::binary_t;
19129 switch (val.type())
19131 case value_t::boolean:
19132 JSONSerializer<other_boolean_t>::to_json(*
this, val.template get<other_boolean_t>());
19134 case value_t::number_float:
19135 JSONSerializer<other_number_float_t>::to_json(*
this, val.template get<other_number_float_t>());
19137 case value_t::number_integer:
19138 JSONSerializer<other_number_integer_t>::to_json(*
this, val.template get<other_number_integer_t>());
19140 case value_t::number_unsigned:
19141 JSONSerializer<other_number_unsigned_t>::to_json(*
this, val.template get<other_number_unsigned_t>());
19143 case value_t::string:
19144 JSONSerializer<other_string_t>::to_json(*
this, val.template get_ref<const other_string_t&>());
19146 case value_t::object:
19147 JSONSerializer<other_object_t>::to_json(*
this, val.template get_ref<const other_object_t&>());
19149 case value_t::array:
19150 JSONSerializer<other_array_t>::to_json(*
this, val.template get_ref<const other_array_t&>());
19152 case value_t::binary:
19153 JSONSerializer<other_binary_t>::to_json(*
this, val.template get_ref<const other_binary_t&>());
19155 case value_t::null:
19158 case value_t::discarded:
19159 m_type = value_t::discarded;
19243 bool type_deduction =
true,
19244 value_t manual_type = value_t::array)
19248 bool is_an_object = std::all_of(init.begin(), init.end(),
19251 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
19255 if (!type_deduction)
19258 if (manual_type == value_t::array)
19260 is_an_object =
false;
19273 m_type = value_t::object;
19276 for (
auto& element_ref : init)
19280 std::move(*((*element.m_value.array)[0].m_value.string)),
19281 std::move((*element.m_value.array)[1]));
19287 m_type = value_t::array;
19288 m_value.array = create<array_t>(init.begin(), init.end());
19326 res.m_type = value_t::binary;
19327 res.m_value = init;
19363 res.m_type = value_t::binary;
19364 res.m_value =
binary_t(init, subtype);
19373 res.m_type = value_t::binary;
19374 res.m_value = std::move(init);
19383 res.m_type = value_t::binary;
19384 res.m_value =
binary_t(std::move(init), subtype);
19428 return basic_json(init,
false, value_t::array);
19472 return basic_json(init,
false, value_t::object);
19500 m_value.array = create<array_t>(cnt, val);
19560 template <
class InputIT,
typename std::enable_if <
19561 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
19562 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >
::type = 0 >
19575 m_type = first.m_object->m_type;
19580 case value_t::boolean:
19581 case value_t::number_float:
19582 case value_t::number_integer:
19583 case value_t::number_unsigned:
19584 case value_t::string:
19587 || !last.m_it.primitive_iterator.is_end()))
19594 case value_t::null:
19595 case value_t::object:
19596 case value_t::array:
19597 case value_t::binary:
19598 case value_t::discarded:
19605 case value_t::number_integer:
19607 m_value.number_integer = first.m_object->m_value.number_integer;
19611 case value_t::number_unsigned:
19613 m_value.number_unsigned = first.m_object->m_value.number_unsigned;
19617 case value_t::number_float:
19619 m_value.number_float = first.m_object->m_value.number_float;
19623 case value_t::boolean:
19625 m_value.boolean = first.m_object->m_value.boolean;
19629 case value_t::string:
19631 m_value = *first.m_object->m_value.string;
19635 case value_t::object:
19637 m_value.object = create<object_t>(first.m_it.object_iterator,
19638 last.m_it.object_iterator);
19642 case value_t::array:
19644 m_value.array = create<array_t>(first.m_it.array_iterator,
19645 last.m_it.array_iterator);
19649 case value_t::binary:
19651 m_value = *first.m_object->m_value.binary;
19655 case value_t::null:
19656 case value_t::discarded:
19670 template<
typename JsonRef,
19672 std::is_same<typename JsonRef::value_type, basic_json>>
::value,
int> = 0 >
19701 : m_type(other.m_type)
19708 case value_t::object:
19714 case value_t::array:
19720 case value_t::string:
19726 case value_t::boolean:
19732 case value_t::number_integer:
19738 case value_t::number_unsigned:
19744 case value_t::number_float:
19750 case value_t::binary:
19756 case value_t::null:
19757 case value_t::discarded:
19793 : m_type(std::move(other.m_type)),
19794 m_value(std::move(other.m_value))
19797 other.assert_invariant(
false);
19800 other.m_type = value_t::null;
19801 other.m_value = {};
19831 std::is_nothrow_move_constructible<value_t>::value&&
19832 std::is_nothrow_move_assignable<value_t>::value&&
19833 std::is_nothrow_move_constructible<json_value>::value&&
19834 std::is_nothrow_move_assignable<json_value>::value
19841 swap(m_type, other.m_type);
19929 const char indent_char =
' ',
19930 const bool ensure_ascii =
false,
19938 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
19942 s.dump(*
this,
false, ensure_ascii, 0);
20063 return m_type == value_t::null;
20085 return m_type == value_t::boolean;
20144 return m_type == value_t::number_integer || m_type == value_t::number_unsigned;
20172 return m_type == value_t::number_unsigned;
20200 return m_type == value_t::number_float;
20222 return m_type == value_t::object;
20244 return m_type == value_t::array;
20266 return m_type == value_t::string;
20288 return m_type == value_t::binary;
20315 return m_type == value_t::discarded;
20469 template<
typename ReferenceType,
typename ThisType>
20473 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
20514 template<
typename PointerType,
typename std::enable_if<
20515 std::is_pointer<PointerType>::value,
int>
::type = 0>
20519 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20526 template <
typename PointerType,
typename std::enable_if <
20527 std::is_pointer<PointerType>::value&&
20528 std::is_const<typename std::remove_pointer<PointerType>::type>
::value,
int >
::type = 0 >
20532 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20574 template <
typename ValueType,
20580 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
20582 auto ret = ValueType();
20583 JSONSerializer<ValueType>::from_json(*
this, ret);
20617 template <
typename ValueType,
20622 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
20624 return JSONSerializer<ValueType>::from_json(*
this);
20642 template <
typename BasicJsonType,
20665 template<
typename BasicJsonType,
20667 std::is_same<BasicJsonType, basic_json_t>::value,
20678 template<
typename PointerType,
20680 std::is_pointer<PointerType>::value,
20683 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
20686 return get_ptr<PointerType>();
20713 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
20714#if defined(JSON_HAS_CPP_14)
20724 static_assert(!std::is_reference<ValueTypeCV>::value,
20725 "get() cannot be used with reference types, you might want to use get_ref()");
20726 return get_impl<ValueType>(detail::priority_tag<4> {});
20756 template<
typename PointerType,
typename std::enable_if<
20757 std::is_pointer<PointerType>::value,
int>
::type = 0>
20761 return get_ptr<PointerType>();
20797 template <
typename ValueType,
20802 ValueType &
get_to(ValueType& v)
const noexcept(
noexcept(
20803 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
20805 JSONSerializer<ValueType>::from_json(*
this, v);
20811 template<
typename ValueType,
20822 typename T, std::size_t N,
20823 typename Array = T (&)[N],
20827 noexcept(
noexcept(JSONSerializer<Array>::from_json(
20828 std::declval<const basic_json_t&>(), v)))
20830 JSONSerializer<Array>::from_json(*
this, v);
20860 template<
typename ReferenceType,
typename std::enable_if<
20861 std::is_reference<ReferenceType>::value,
int>
::type = 0>
20865 return get_ref_impl<ReferenceType>(*
this);
20872 template <
typename ReferenceType,
typename std::enable_if <
20873 std::is_reference<ReferenceType>::value&&
20874 std::is_const<typename std::remove_reference<ReferenceType>::type>
::value,
int >
::type = 0 >
20878 return get_ref_impl<ReferenceType>(*
this);
20910 template <
typename ValueType,
typename std::enable_if <
20918#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
20926 return get<ValueType>();
20945 return *get_ptr<binary_t*>();
20956 return *get_ptr<const binary_t*>();
21050 return m_value.array->at(idx);
21152 return m_value.object->at(key);
21196 m_type = value_t::array;
21197 m_value.array = create<array_t>();
21205 if (idx >=
m_value.array->size())
21207#if JSON_DIAGNOSTICS
21209 const auto old_size =
m_value.array->size();
21210 const auto old_capacity =
m_value.array->capacity();
21212 m_value.array->resize(idx + 1);
21214#if JSON_DIAGNOSTICS
21229 return m_value.array->operator[](idx);
21259 return m_value.array->operator[](idx);
21297 m_type = value_t::object;
21298 m_value.object = create<object_t>();
21347 return m_value.object->find(key)->second;
21380 template<
typename T>
21387 m_type = value_t::object;
21431 template<
typename T>
21439 return m_value.object->find(key)->second;
21496 template <
class ValueType,
typename std::enable_if <
21498 && !std::is_same<value_t, ValueType>::value,
int >
::type = 0 >
21499 ValueType
value(
const typename object_t::key_type& key,
const ValueType& default_value)
const
21505 const auto it =
find(key);
21508 return it->template get<ValueType>();
21511 return default_value;
21521 string_t value(
const typename object_t::key_type& key,
const char* default_value)
const
21569 template<
class ValueType,
typename std::enable_if<
21579 return ptr.
get_checked(
this).template get<ValueType>();
21583 return default_value;
21732 template <
class IteratorType,
typename std::enable_if <
21733 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21734 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int >
::type
21744 IteratorType result =
end();
21748 case value_t::boolean:
21749 case value_t::number_float:
21750 case value_t::number_integer:
21751 case value_t::number_unsigned:
21752 case value_t::string:
21753 case value_t::binary:
21762 AllocatorType<string_t> alloc;
21764 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
21769 AllocatorType<binary_t> alloc;
21771 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
21775 m_type = value_t::null;
21780 case value_t::object:
21782 result.m_it.object_iterator =
m_value.object->erase(pos.m_it.object_iterator);
21786 case value_t::array:
21788 result.m_it.array_iterator =
m_value.array->erase(pos.m_it.array_iterator);
21792 case value_t::null:
21793 case value_t::discarded:
21847 template <
class IteratorType,
typename std::enable_if <
21848 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21849 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int >
::type
21851 IteratorType
erase(IteratorType first, IteratorType last)
21859 IteratorType result =
end();
21863 case value_t::boolean:
21864 case value_t::number_float:
21865 case value_t::number_integer:
21866 case value_t::number_unsigned:
21867 case value_t::string:
21868 case value_t::binary:
21871 || !last.m_it.primitive_iterator.is_end()))
21878 AllocatorType<string_t> alloc;
21880 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.string, 1);
21885 AllocatorType<binary_t> alloc;
21887 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
m_value.binary, 1);
21891 m_type = value_t::null;
21896 case value_t::object:
21898 result.m_it.object_iterator =
m_value.object->erase(first.m_it.object_iterator,
21899 last.m_it.object_iterator);
21903 case value_t::array:
21905 result.m_it.array_iterator =
m_value.array->erase(first.m_it.array_iterator,
21906 last.m_it.array_iterator);
21910 case value_t::null:
21911 case value_t::discarded:
21953 return m_value.object->erase(key);
22035 template<
typename KeyT>
22038 auto result =
end();
22042 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyT>(key));
22052 template<
typename KeyT>
22055 auto result =
cend();
22059 result.m_it.object_iterator =
m_value.object->find(std::forward<KeyT>(key));
22086 template<
typename KeyT>
22118 template <
typename KeyT,
typename std::enable_if <
22193 result.set_begin();
22233 result.set_begin();
22500 return ref.items();
22509 return ref.items();
22649 case value_t::null:
22655 case value_t::array:
22658 return m_value.array->empty();
22661 case value_t::object:
22664 return m_value.object->empty();
22667 case value_t::string:
22668 case value_t::boolean:
22669 case value_t::number_integer:
22670 case value_t::number_unsigned:
22671 case value_t::number_float:
22672 case value_t::binary:
22673 case value_t::discarded:
22729 case value_t::null:
22735 case value_t::array:
22738 return m_value.array->size();
22741 case value_t::object:
22744 return m_value.object->size();
22747 case value_t::string:
22748 case value_t::boolean:
22749 case value_t::number_integer:
22750 case value_t::number_unsigned:
22751 case value_t::number_float:
22752 case value_t::binary:
22753 case value_t::discarded:
22807 case value_t::array:
22810 return m_value.array->max_size();
22813 case value_t::object:
22816 return m_value.object->max_size();
22819 case value_t::null:
22820 case value_t::string:
22821 case value_t::boolean:
22822 case value_t::number_integer:
22823 case value_t::number_unsigned:
22824 case value_t::number_float:
22825 case value_t::binary:
22826 case value_t::discarded:
22886 case value_t::number_integer:
22892 case value_t::number_unsigned:
22898 case value_t::number_float:
22904 case value_t::boolean:
22910 case value_t::string:
22916 case value_t::binary:
22922 case value_t::array:
22928 case value_t::object:
22934 case value_t::null:
22935 case value_t::discarded:
22972 m_type = value_t::array;
22978 const auto old_capacity =
m_value.array->capacity();
22979 m_value.array->push_back(std::move(val));
23009 m_type = value_t::array;
23015 const auto old_capacity =
m_value.array->capacity();
23016 m_value.array->push_back(val);
23061 m_type = value_t::object;
23067 auto res =
m_value.object->insert(val);
23108 if (
is_object() && init.size() == 2 && (*init.begin())->is_string())
23110 basic_json&& key = init.begin()->moved_or_copied();
23111 push_back(
typename object_t::value_type(
23112 std::move(key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
23153 template<
class... Args>
23165 m_type = value_t::array;
23171 const auto old_capacity =
m_value.array->capacity();
23172 m_value.array->emplace_back(std::forward<Args>(args)...);
23203 template<
class... Args>
23215 m_type = value_t::object;
23221 auto res =
m_value.object->emplace(std::forward<Args>(args)...);
23226 it.m_it.object_iterator = res.first;
23229 return {it, res.second};
23235 template<
typename... Args>
23299 return insert(pos, val);
23551 m_type = value_t::object;
23552 m_value.object = create<object_t>();
23573 for (
auto it = first; it != last; ++it)
23575 if (merge_objects && it.value().is_object())
23577 auto it2 =
m_value.object->find(it.key());
23578 if (it2 !=
m_value.object->end())
23580 it2->second.update(it.value(),
true);
23584 m_value.object->operator[](it.key()) = it.value();
23585#if JSON_DIAGNOSTICS
23586 m_value.object->operator[](it.key()).m_parent =
this;
23609 std::is_nothrow_move_constructible<value_t>::value&&
23610 std::is_nothrow_move_assignable<value_t>::value&&
23611 std::is_nothrow_move_constructible<json_value>::value&&
23612 std::is_nothrow_move_assignable<json_value>::value
23619 other.set_parents();
23642 std::is_nothrow_move_constructible<value_t>::value&&
23643 std::is_nothrow_move_assignable<value_t>::value&&
23644 std::is_nothrow_move_constructible<json_value>::value&&
23645 std::is_nothrow_move_assignable<json_value>::value
23865#pragma GCC diagnostic push
23866#pragma GCC diagnostic ignored "-Wfloat-equal"
23868 const auto lhs_type = lhs.type();
23869 const auto rhs_type = rhs.type();
23871 if (lhs_type == rhs_type)
23875 case value_t::array:
23876 return *lhs.m_value.array == *rhs.m_value.array;
23878 case value_t::object:
23879 return *lhs.m_value.object == *rhs.m_value.object;
23881 case value_t::null:
23884 case value_t::string:
23885 return *lhs.m_value.string == *rhs.m_value.string;
23887 case value_t::boolean:
23888 return lhs.m_value.boolean == rhs.m_value.boolean;
23890 case value_t::number_integer:
23891 return lhs.m_value.number_integer == rhs.m_value.number_integer;
23893 case value_t::number_unsigned:
23894 return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
23896 case value_t::number_float:
23897 return lhs.m_value.number_float == rhs.m_value.number_float;
23899 case value_t::binary:
23900 return *lhs.m_value.binary == *rhs.m_value.binary;
23902 case value_t::discarded:
23907 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float)
23909 return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
23911 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer)
23913 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_integer);
23915 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float)
23917 return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
23919 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned)
23921 return lhs.m_value.number_float ==
static_cast<number_float_t>(rhs.m_value.number_unsigned);
23923 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer)
23925 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
23927 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned)
23929 return lhs.m_value.number_integer ==
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
23934#pragma GCC diagnostic pop
23942 template<
typename ScalarType,
typename std::enable_if<
23943 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23953 template<
typename ScalarType,
typename std::enable_if<
23954 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23980 return !(lhs == rhs);
23987 template<
typename ScalarType,
typename std::enable_if<
23988 std::is_scalar<ScalarType>::value,
int>
::type = 0>
23998 template<
typename ScalarType,
typename std::enable_if<
23999 std::is_scalar<ScalarType>::value,
int>
::type = 0>
24033 const auto lhs_type = lhs.type();
24034 const auto rhs_type = rhs.type();
24036 if (lhs_type == rhs_type)
24040 case value_t::array:
24043 return (*lhs.m_value.array) < (*rhs.m_value.array);
24045 case value_t::object:
24046 return (*lhs.m_value.object) < (*rhs.m_value.object);
24048 case value_t::null:
24051 case value_t::string:
24052 return (*lhs.m_value.string) < (*rhs.m_value.string);
24054 case value_t::boolean:
24055 return (lhs.m_value.boolean) < (rhs.m_value.boolean);
24057 case value_t::number_integer:
24058 return (lhs.m_value.number_integer) < (rhs.m_value.number_integer);
24060 case value_t::number_unsigned:
24061 return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned);
24063 case value_t::number_float:
24064 return (lhs.m_value.number_float) < (rhs.m_value.number_float);
24066 case value_t::binary:
24067 return (*lhs.m_value.binary) < (*rhs.m_value.binary);
24069 case value_t::discarded:
24074 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float)
24076 return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
24078 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer)
24080 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_integer);
24082 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float)
24084 return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
24086 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned)
24088 return lhs.m_value.number_float <
static_cast<number_float_t>(rhs.m_value.number_unsigned);
24090 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned)
24092 return lhs.m_value.number_integer <
static_cast<number_integer_t>(rhs.m_value.number_unsigned);
24094 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer)
24096 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
24109 template<
typename ScalarType,
typename std::enable_if<
24110 std::is_scalar<ScalarType>::value,
int>
::type = 0>
24120 template<
typename ScalarType,
typename std::enable_if<
24121 std::is_scalar<ScalarType>::value,
int>
::type = 0>
24148 return !(rhs < lhs);
24155 template<
typename ScalarType,
typename std::enable_if<
24156 std::is_scalar<ScalarType>::value,
int>
::type = 0>
24166 template<
typename ScalarType,
typename std::enable_if<
24167 std::is_scalar<ScalarType>::value,
int>
::type = 0>
24194 return !(lhs <= rhs);
24201 template<
typename ScalarType,
typename std::enable_if<
24202 std::is_scalar<ScalarType>::value,
int>
::type = 0>
24212 template<
typename ScalarType,
typename std::enable_if<
24213 std::is_scalar<ScalarType>::value,
int>
::type = 0>
24240 return !(lhs < rhs);
24247 template<
typename ScalarType,
typename std::enable_if<
24248 std::is_scalar<ScalarType>::value,
int>
::type = 0>
24258 template<
typename ScalarType,
typename std::enable_if<
24259 std::is_scalar<ScalarType>::value,
int>
::type = 0>
24308 const bool pretty_print = o.width() > 0;
24309 const auto indentation = pretty_print ? o.width() : 0;
24316 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
24395 template<
typename InputType>
24399 const bool allow_exceptions =
true,
24400 const bool ignore_comments =
false)
24433 template<
typename IteratorType>
24438 const bool allow_exceptions =
true,
24439 const bool ignore_comments =
false)
24450 const
bool allow_exceptions = true,
24451 const
bool ignore_comments = false)
24454 parser(i.get(), cb, allow_exceptions, ignore_comments).parse(
true, result);
24488 template<
typename InputType>
24490 const bool ignore_comments =
false)
24495 template<
typename IteratorType>
24496 static bool accept(IteratorType first, IteratorType last,
24497 const bool ignore_comments =
false)
24504 static
bool accept(detail::span_input_adapter&& i,
24505 const
bool ignore_comments = false)
24507 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
24550 template <
typename InputType,
typename SAX>
24554 const
bool strict = true,
24555 const
bool ignore_comments = false)
24558 return format == input_format_t::json
24559 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
24563 template<
class IteratorType,
class SAX>
24565 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
24567 const
bool strict = true,
24568 const
bool ignore_comments = false)
24571 return format == input_format_t::json
24572 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
24576 template <
typename SAX>
24581 const
bool strict = true,
24582 const
bool ignore_comments = false)
24585 return format == input_format_t::json
24587 ?
parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
24680 case value_t::null:
24682 case value_t::object:
24684 case value_t::array:
24686 case value_t::string:
24688 case value_t::boolean:
24690 case value_t::binary:
24692 case value_t::discarded:
24693 return "discarded";
24694 case value_t::number_integer:
24695 case value_t::number_unsigned:
24696 case value_t::number_float:
24710 value_t m_type = value_t::null;
24715#if JSON_DIAGNOSTICS
24828 std::vector<std::uint8_t> result;
24923 std::vector<std::uint8_t> result;
25025 const bool use_size =
false,
25026 const bool use_type =
false)
25028 std::vector<std::uint8_t> result;
25029 to_ubjson(j, result, use_size, use_type);
25034 const bool use_size =
false,
const bool use_type =
false)
25040 const bool use_size =
false,
const bool use_type =
false)
25104 std::vector<std::uint8_t> result;
25233 template<
typename InputType>
25236 const bool strict =
true,
25237 const bool allow_exceptions =
true,
25244 return res ? result :
basic_json(value_t::discarded);
25250 template<
typename IteratorType>
25253 const bool strict =
true,
25254 const bool allow_exceptions =
true,
25261 return res ? result :
basic_json(value_t::discarded);
25264 template<
typename T>
25268 const
bool strict = true,
25269 const
bool allow_exceptions = true,
25272 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
25279 const
bool strict = true,
25280 const
bool allow_exceptions = true,
25288 return res ? result :
basic_json(value_t::discarded);
25377 template<
typename InputType>
25380 const bool strict =
true,
25381 const bool allow_exceptions =
true)
25387 return res ? result :
basic_json(value_t::discarded);
25393 template<
typename IteratorType>
25396 const bool strict =
true,
25397 const bool allow_exceptions =
true)
25403 return res ? result :
basic_json(value_t::discarded);
25407 template<
typename T>
25411 const
bool strict = true,
25412 const
bool allow_exceptions = true)
25414 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
25420 const
bool strict = true,
25421 const
bool allow_exceptions = true)
25428 return res ? result :
basic_json(value_t::discarded);
25494 template<
typename InputType>
25497 const bool strict =
true,
25498 const bool allow_exceptions =
true)
25504 return res ? result :
basic_json(value_t::discarded);
25510 template<
typename IteratorType>
25513 const bool strict =
true,
25514 const bool allow_exceptions =
true)
25520 return res ? result :
basic_json(value_t::discarded);
25523 template<
typename T>
25527 const
bool strict = true,
25528 const
bool allow_exceptions = true)
25530 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
25536 const
bool strict = true,
25537 const
bool allow_exceptions = true)
25544 return res ? result :
basic_json(value_t::discarded);
25608 template<
typename InputType>
25611 const bool strict =
true,
25612 const bool allow_exceptions =
true)
25618 return res ? result :
basic_json(value_t::discarded);
25624 template<
typename IteratorType>
25627 const bool strict =
true,
25628 const bool allow_exceptions =
true)
25634 return res ? result :
basic_json(value_t::discarded);
25637 template<
typename T>
25641 const
bool strict = true,
25642 const
bool allow_exceptions = true)
25644 return from_bson(ptr, ptr + len, strict, allow_exceptions);
25650 const
bool strict = true,
25651 const
bool allow_exceptions = true)
25658 return res ? result :
basic_json(value_t::discarded);
25947 enum class patch_operations {add, remove, replace, move, copy, test, invalid};
25949 const auto get_op = [](
const std::string & op)
25953 return patch_operations::add;
25955 if (op ==
"remove")
25957 return patch_operations::remove;
25959 if (op ==
"replace")
25961 return patch_operations::replace;
25965 return patch_operations::move;
25969 return patch_operations::copy;
25973 return patch_operations::test;
25976 return patch_operations::invalid;
25991 if (top_pointer != ptr)
25993 result.
at(top_pointer);
25997 const auto last_path = ptr.
back();
26001 switch (parent.m_type)
26003 case value_t::null:
26004 case value_t::object:
26007 parent[last_path] = val;
26011 case value_t::array:
26013 if (last_path ==
"-")
26034 case value_t::string:
26035 case value_t::boolean:
26036 case value_t::number_integer:
26037 case value_t::number_unsigned:
26038 case value_t::number_float:
26039 case value_t::binary:
26040 case value_t::discarded:
26047 const auto operation_remove = [
this, &result](
json_pointer & ptr)
26050 const auto last_path = ptr.
back();
26058 auto it = parent.
find(last_path);
26082 for (
const auto& val : json_patch)
26085 const auto get_value = [&val](
const std::string & op,
26086 const std::string & member,
26090 auto it = val.
m_value.object->find(member);
26093 const auto error_msg = (op ==
"op") ?
"operation" :
"operation '" + op +
"'";
26120 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
26121 const auto path = get_value(op,
"path",
true).template get<std::string>();
26124 switch (get_op(op))
26126 case patch_operations::add:
26128 operation_add(ptr, get_value(
"add",
"value",
false));
26132 case patch_operations::remove:
26134 operation_remove(ptr);
26138 case patch_operations::replace:
26141 result.
at(ptr) = get_value(
"replace",
"value",
false);
26145 case patch_operations::move:
26147 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
26157 operation_remove(from_ptr);
26158 operation_add(ptr, v);
26162 case patch_operations::copy:
26164 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
26173 operation_add(ptr, v);
26177 case patch_operations::test:
26179 bool success =
false;
26184 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
26200 case patch_operations::invalid:
26248 const std::string& path =
"")
26254 if (source == target)
26259 if (source.
type() != target.
type())
26264 {
"op",
"replace"}, {
"path", path}, {
"value", target}
26269 switch (source.
type())
26271 case value_t::array:
26275 while (i < source.
size() && i < target.
size())
26278 auto temp_diff =
diff(source[i], target[i], path +
"/" + std::to_string(i));
26279 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
26288 while (i < source.
size())
26295 {
"path", path +
"/" + std::to_string(i)}
26301 while (i < target.
size())
26306 {
"path", path +
"/-"},
26307 {
"value", target[i]}
26315 case value_t::object:
26318 for (
auto it = source.
cbegin(); it != source.
cend(); ++it)
26323 if (target.
find(it.key()) != target.
end())
26326 auto temp_diff =
diff(it.value(), target[it.key()], path_key);
26327 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
26334 {
"op",
"remove"}, {
"path", path_key}
26340 for (
auto it = target.
cbegin(); it != target.
cend(); ++it)
26342 if (source.
find(it.key()) == source.
end())
26348 {
"op",
"add"}, {
"path", path_key},
26349 {
"value", it.value()}
26357 case value_t::null:
26358 case value_t::string:
26359 case value_t::boolean:
26360 case value_t::number_integer:
26361 case value_t::number_unsigned:
26362 case value_t::number_float:
26363 case value_t::binary:
26364 case value_t::discarded:
26370 {
"op",
"replace"}, {
"path", path}, {
"value", target}
26438 for (
auto it = apply_patch.
begin(); it != apply_patch.
end(); ++it)
26440 if (it.value().is_null())
26452 *
this = apply_patch;
26491 std::size_t
operator()(
const nlohmann::NLOHMANN_BASIC_JSON_TPL& j)
const
26515#ifndef JSON_HAS_CPP_20
26523inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2)
noexcept(
26524 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
26525 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
26576#if defined(__clang__)
26577 #pragma clang diagnostic pop
26582#undef JSON_INTERNAL_CATCH
26586#undef JSON_PRIVATE_UNLESS_TESTED
26587#undef JSON_HAS_CPP_11
26588#undef JSON_HAS_CPP_14
26589#undef JSON_HAS_CPP_17
26590#undef JSON_HAS_CPP_20
26591#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
26592#undef NLOHMANN_BASIC_JSON_TPL
26593#undef JSON_EXPLICIT
26594#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
26599#undef JSON_HEDLEY_ALWAYS_INLINE
26600#undef JSON_HEDLEY_ARM_VERSION
26601#undef JSON_HEDLEY_ARM_VERSION_CHECK
26602#undef JSON_HEDLEY_ARRAY_PARAM
26603#undef JSON_HEDLEY_ASSUME
26604#undef JSON_HEDLEY_BEGIN_C_DECLS
26605#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
26606#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
26607#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
26608#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
26609#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
26610#undef JSON_HEDLEY_CLANG_HAS_FEATURE
26611#undef JSON_HEDLEY_CLANG_HAS_WARNING
26612#undef JSON_HEDLEY_COMPCERT_VERSION
26613#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
26614#undef JSON_HEDLEY_CONCAT
26615#undef JSON_HEDLEY_CONCAT3
26616#undef JSON_HEDLEY_CONCAT3_EX
26617#undef JSON_HEDLEY_CONCAT_EX
26618#undef JSON_HEDLEY_CONST
26619#undef JSON_HEDLEY_CONSTEXPR
26620#undef JSON_HEDLEY_CONST_CAST
26621#undef JSON_HEDLEY_CPP_CAST
26622#undef JSON_HEDLEY_CRAY_VERSION
26623#undef JSON_HEDLEY_CRAY_VERSION_CHECK
26624#undef JSON_HEDLEY_C_DECL
26625#undef JSON_HEDLEY_DEPRECATED
26626#undef JSON_HEDLEY_DEPRECATED_FOR
26627#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
26628#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
26629#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
26630#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
26631#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
26632#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
26633#undef JSON_HEDLEY_DIAGNOSTIC_POP
26634#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
26635#undef JSON_HEDLEY_DMC_VERSION
26636#undef JSON_HEDLEY_DMC_VERSION_CHECK
26637#undef JSON_HEDLEY_EMPTY_BASES
26638#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
26639#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
26640#undef JSON_HEDLEY_END_C_DECLS
26641#undef JSON_HEDLEY_FLAGS
26642#undef JSON_HEDLEY_FLAGS_CAST
26643#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
26644#undef JSON_HEDLEY_GCC_HAS_BUILTIN
26645#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
26646#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
26647#undef JSON_HEDLEY_GCC_HAS_EXTENSION
26648#undef JSON_HEDLEY_GCC_HAS_FEATURE
26649#undef JSON_HEDLEY_GCC_HAS_WARNING
26650#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
26651#undef JSON_HEDLEY_GCC_VERSION
26652#undef JSON_HEDLEY_GCC_VERSION_CHECK
26653#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
26654#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
26655#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
26656#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
26657#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
26658#undef JSON_HEDLEY_GNUC_HAS_FEATURE
26659#undef JSON_HEDLEY_GNUC_HAS_WARNING
26660#undef JSON_HEDLEY_GNUC_VERSION
26661#undef JSON_HEDLEY_GNUC_VERSION_CHECK
26662#undef JSON_HEDLEY_HAS_ATTRIBUTE
26663#undef JSON_HEDLEY_HAS_BUILTIN
26664#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
26665#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
26666#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
26667#undef JSON_HEDLEY_HAS_EXTENSION
26668#undef JSON_HEDLEY_HAS_FEATURE
26669#undef JSON_HEDLEY_HAS_WARNING
26670#undef JSON_HEDLEY_IAR_VERSION
26671#undef JSON_HEDLEY_IAR_VERSION_CHECK
26672#undef JSON_HEDLEY_IBM_VERSION
26673#undef JSON_HEDLEY_IBM_VERSION_CHECK
26674#undef JSON_HEDLEY_IMPORT
26675#undef JSON_HEDLEY_INLINE
26676#undef JSON_HEDLEY_INTEL_CL_VERSION
26677#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
26678#undef JSON_HEDLEY_INTEL_VERSION
26679#undef JSON_HEDLEY_INTEL_VERSION_CHECK
26680#undef JSON_HEDLEY_IS_CONSTANT
26681#undef JSON_HEDLEY_IS_CONSTEXPR_
26682#undef JSON_HEDLEY_LIKELY
26683#undef JSON_HEDLEY_MALLOC
26684#undef JSON_HEDLEY_MCST_LCC_VERSION
26685#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
26686#undef JSON_HEDLEY_MESSAGE
26687#undef JSON_HEDLEY_MSVC_VERSION
26688#undef JSON_HEDLEY_MSVC_VERSION_CHECK
26689#undef JSON_HEDLEY_NEVER_INLINE
26690#undef JSON_HEDLEY_NON_NULL
26691#undef JSON_HEDLEY_NO_ESCAPE
26692#undef JSON_HEDLEY_NO_RETURN
26693#undef JSON_HEDLEY_NO_THROW
26694#undef JSON_HEDLEY_NULL
26695#undef JSON_HEDLEY_PELLES_VERSION
26696#undef JSON_HEDLEY_PELLES_VERSION_CHECK
26697#undef JSON_HEDLEY_PGI_VERSION
26698#undef JSON_HEDLEY_PGI_VERSION_CHECK
26699#undef JSON_HEDLEY_PREDICT
26700#undef JSON_HEDLEY_PRINTF_FORMAT
26701#undef JSON_HEDLEY_PRIVATE
26702#undef JSON_HEDLEY_PUBLIC
26703#undef JSON_HEDLEY_PURE
26704#undef JSON_HEDLEY_REINTERPRET_CAST
26705#undef JSON_HEDLEY_REQUIRE
26706#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
26707#undef JSON_HEDLEY_REQUIRE_MSG
26708#undef JSON_HEDLEY_RESTRICT
26709#undef JSON_HEDLEY_RETURNS_NON_NULL
26710#undef JSON_HEDLEY_SENTINEL
26711#undef JSON_HEDLEY_STATIC_ASSERT
26712#undef JSON_HEDLEY_STATIC_CAST
26713#undef JSON_HEDLEY_STRINGIFY
26714#undef JSON_HEDLEY_STRINGIFY_EX
26715#undef JSON_HEDLEY_SUNPRO_VERSION
26716#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
26717#undef JSON_HEDLEY_TINYC_VERSION
26718#undef JSON_HEDLEY_TINYC_VERSION_CHECK
26719#undef JSON_HEDLEY_TI_ARMCL_VERSION
26720#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
26721#undef JSON_HEDLEY_TI_CL2000_VERSION
26722#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
26723#undef JSON_HEDLEY_TI_CL430_VERSION
26724#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
26725#undef JSON_HEDLEY_TI_CL6X_VERSION
26726#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
26727#undef JSON_HEDLEY_TI_CL7X_VERSION
26728#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
26729#undef JSON_HEDLEY_TI_CLPRU_VERSION
26730#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
26731#undef JSON_HEDLEY_TI_VERSION
26732#undef JSON_HEDLEY_TI_VERSION_CHECK
26733#undef JSON_HEDLEY_UNAVAILABLE
26734#undef JSON_HEDLEY_UNLIKELY
26735#undef JSON_HEDLEY_UNPREDICTABLE
26736#undef JSON_HEDLEY_UNREACHABLE
26737#undef JSON_HEDLEY_UNREACHABLE_RETURN
26738#undef JSON_HEDLEY_VERSION
26739#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
26740#undef JSON_HEDLEY_VERSION_DECODE_MINOR
26741#undef JSON_HEDLEY_VERSION_DECODE_REVISION
26742#undef JSON_HEDLEY_VERSION_ENCODE
26743#undef JSON_HEDLEY_WARNING
26744#undef JSON_HEDLEY_WARN_UNUSED_RESULT
26745#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
26746#undef JSON_HEDLEY_FALL_THROUGH
a class to store JSON values
Definition: json.hpp:17717
ValueType & get_to(ValueType &v) const
Definition: json.hpp:20815
void insert(const_iterator first, const_iterator last)
inserts elements
Definition: json.hpp:23468
array_t * get_impl_ptr(array_t *) noexcept
get a pointer to the value (array)
Definition: json.hpp:20375
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
Definition: json.hpp:18943
bool contains(KeyT &&key) const
check the existence of an element in a JSON object
Definition: json.hpp:22120
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
Definition: json.hpp:22580
const_reverse_iterator crbegin() const noexcept
returns a const reverse iterator to the last element
Definition: json.hpp:22405
constexpr const number_unsigned_t * get_impl_ptr(const number_unsigned_t *) const noexcept
get a pointer to the value (unsigned number)
Definition: json.hpp:20429
number_unsigned_t number_unsigned
number (unsigned integer)
Definition: json.hpp:18529
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
Definition: json.hpp:25730
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
Definition: json.hpp:25702
friend bool operator==(const_reference lhs, ScalarType rhs) noexcept
comparison: equal
Definition: json.hpp:23944
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
Definition: json.hpp:21499
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
Definition: json.hpp:20198
NumberIntegerType number_integer_t
a type for a number (integer)
Definition: json.hpp:18251
friend bool operator==(const_reference lhs, const_reference rhs) noexcept
comparison: equal
Definition: json.hpp:23862
NLOHMANN_BASIC_JSON_TPL basic_json_t
workaround type for MSVC
Definition: json.hpp:17738
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition: json.hpp:23513
static bool sax_parse(InputType &&i, SAX *sax, input_format_t format=input_format_t::json, const bool strict=true, const bool ignore_comments=false)
generate SAX events
Definition: json.hpp:24552
ReferenceType get_ref()
get a reference value (implicit)
Definition: json.hpp:20862
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(InputType &&i, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a compatible input
Definition: json.hpp:24397
reference emplace_back(Args &&... args)
add an object to an array
Definition: json.hpp:23154
const_iterator find(KeyT &&key) const
find an element in a JSON object
Definition: json.hpp:22053
basic_json(const value_t v)
create an empty value with a given type
Definition: json.hpp:18984
object_t * get_impl_ptr(object_t *) noexcept
get a pointer to the value (object)
Definition: json.hpp:20363
size_type max_size() const noexcept
returns the maximum possible number of elements
Definition: json.hpp:22803
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const std::string &path="")
creates a diff as a JSON patch
Definition: json.hpp:26247
static std::vector< std::uint8_t > to_bson(const basic_json &j)
Serializes the given JSON object j to BSON and returns a vector containing the corresponding BSON-rep...
Definition: json.hpp:25102
void erase(const size_type idx)
remove element from a JSON array given an index
Definition: json.hpp:21983
const_reverse_iterator crend() const noexcept
returns a const reverse iterator to one before the first
Definition: json.hpp:22434
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
Definition: json.hpp:21145
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
Definition: json.hpp:21094
iterator begin() noexcept
returns an iterator to the first element
Definition: json.hpp:22190
binary_t & get_binary()
Definition: json.hpp:20938
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
Definition: json.hpp:19563
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
Definition: json.hpp:24921
friend bool operator==(ScalarType lhs, const_reference rhs) noexcept
comparison: equal
Definition: json.hpp:23955
json_value(object_t &&value)
constructor for rvalue objects
Definition: json.hpp:18625
basic_json(const JsonRef &ref)
Definition: json.hpp:19673
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
Definition: json.hpp:24826
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
copy assignment
Definition: json.hpp:19830
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
Definition: json.hpp:19426
json_value(number_float_t v) noexcept
constructor for numbers (floating-point)
Definition: json.hpp:18542
const_reverse_iterator rend() const noexcept
returns a const reverse iterator to one before the first
Definition: json.hpp:22376
void assert_invariant(bool check_parents=true) const noexcept
checks the class invariants
Definition: json.hpp:18763
json_value(string_t &&value)
constructor for rvalue strings
Definition: json.hpp:18619
const_iterator cend() const noexcept
returns a const iterator to one past the last element
Definition: json.hpp:22301
json_value(number_integer_t v) noexcept
constructor for numbers (integer)
Definition: json.hpp:18538
number_unsigned_t * get_impl_ptr(number_unsigned_t *) noexcept
get a pointer to the value (unsigned number)
Definition: json.hpp:20423
reference back()
access the last element
Definition: json.hpp:21669
boolean_t * get_impl_ptr(boolean_t *) noexcept
get a pointer to the value (boolean)
Definition: json.hpp:20399
const binary_t & get_binary() const
Definition: json.hpp:20949
constexpr const boolean_t * get_impl_ptr(const boolean_t *) const noexcept
get a pointer to the value (boolean)
Definition: json.hpp:20405
static bool accept(InputType &&i, const bool ignore_comments=false)
check if the input is valid JSON
Definition: json.hpp:24489
StringType string_t
a type for a string
Definition: json.hpp:18153
size_type size() const noexcept
returns the number of elements
Definition: json.hpp:22725
void push_back(const basic_json &val)
add an object to an array
Definition: json.hpp:22998
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
Definition: json.hpp:17894
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
Definition: json.hpp:21571
std::size_t size_type
a type to represent container sizes
Definition: json.hpp:17837
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
Definition: json.hpp:20802
std::ptrdiff_t difference_type
a type to represent differences between iterators
Definition: json.hpp:17835
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
Definition: json.hpp:19323
reference operator[](const typename object_t::key_type &key)
access specified object element
Definition: json.hpp:21292
json_value(number_unsigned_t v) noexcept
constructor for numbers (unsigned)
Definition: json.hpp:18540
reference operator+=(basic_json &&val)
add an object to an array
Definition: json.hpp:22988
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
Definition: json.hpp:19118
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
Definition: json.hpp:17845
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
Create a JSON value from an input in BSON format.
Definition: json.hpp:25626
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
Definition: json.hpp:17843
constexpr const binary_t * get_impl_ptr(const binary_t *) const noexcept
get a pointer to the value (binary)
Definition: json.hpp:20453
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition: json.hpp:25235
BooleanType boolean_t
a type for a boolean
Definition: json.hpp:18179
iterator set_parents(iterator it, typename iterator::difference_type count_set_parents)
Definition: json.hpp:18821
void push_back(initializer_list_t init)
add an object to an object
Definition: json.hpp:23106
boolean_t get_impl(boolean_t *) const
get a boolean (explicit)
Definition: json.hpp:20352
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
Definition: json.hpp:19928
static bool accept(IteratorType first, IteratorType last, const bool ignore_comments=false)
Definition: json.hpp:24496
IteratorType erase(IteratorType pos)
remove element given an iterator
Definition: json.hpp:21736
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
Serializes the given JSON object j to BSON and forwards the corresponding BSON-representation to the ...
Definition: json.hpp:25117
friend bool operator!=(const_reference lhs, ScalarType rhs) noexcept
comparison: not equal
Definition: json.hpp:23989
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
Create a JSON value from an input in BSON format.
Definition: json.hpp:25610
constexpr bool is_structured() const noexcept
return whether type is structured
Definition: json.hpp:20039
friend bool operator<=(ScalarType lhs, const_reference rhs) noexcept
comparison: less than or equal
Definition: json.hpp:24168
const_iterator begin() const noexcept
returns a const iterator to the first element
Definition: json.hpp:22200
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
Definition: json.hpp:23546
friend bool operator<(const_reference lhs, ScalarType rhs) noexcept
comparison: less than
Definition: json.hpp:24111
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:20996
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
binary (stored with pointer to save storage)
Definition: json.hpp:19380
reference front()
access the first element
Definition: json.hpp:21625
constexpr bool is_primitive() const noexcept
return whether type is primitive
Definition: json.hpp:20012
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
Definition: json.hpp:20170
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
Definition: json.hpp:24838
void swap(object_t &other)
exchanges the values
Definition: json.hpp:23704
constexpr bool is_object() const noexcept
return whether value is an object
Definition: json.hpp:20220
const_reference front() const
access the first element
Definition: json.hpp:21633
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
Definition: json.hpp:19981
NumberFloatType number_float_t
a type for a number (floating-point)
Definition: json.hpp:18390
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
Definition: json.hpp:17852
friend std::ostream & operator<<(std::ostream &o, const basic_json &j)
serialize to stream
Definition: json.hpp:24305
friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
comparison: less than or equal
Definition: json.hpp:24146
bool empty() const noexcept
checks whether the container is empty.
Definition: json.hpp:22645
json_value(value_t t)
constructor for empty values of a given type
Definition: json.hpp:18544
basic_json(const basic_json &other)
copy constructor
Definition: json.hpp:19700
~basic_json() noexcept
destructor
Definition: json.hpp:19864
static std::vector< std::uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Definition: json.hpp:25024
basic_json(basic_json &&other) noexcept
move constructor
Definition: json.hpp:19792
friend bool operator>(ScalarType lhs, const_reference rhs) noexcept
comparison: greater than
Definition: json.hpp:24214
BasicJsonType get_impl(detail::priority_tag< 2 >) const
get special-case overload
Definition: json.hpp:20646
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
Definition: json.hpp:25039
friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
comparison: not equal
Definition: json.hpp:23978
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts elements
Definition: json.hpp:23326
friend bool operator<(ScalarType lhs, const_reference rhs) noexcept
comparison: less than
Definition: json.hpp:24122
json_value m_value
the value of the current element
Definition: json.hpp:24713
boolean_t boolean
boolean
Definition: json.hpp:18525
void swap(typename binary_t::container_type &other)
exchanges the values
Definition: json.hpp:23784
friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
comparison: greater than or equal
Definition: json.hpp:24238
void swap(array_t &other)
exchanges the values
Definition: json.hpp:23671
ValueType get_impl(detail::priority_tag< 0 >) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), std::declval< ValueType & >())))
get a value (explicit)
Definition: json.hpp:20579
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
Definition: json.hpp:22368
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
Definition: json.hpp:19360
static iteration_proxy< iterator > iterator_wrapper(reference ref) noexcept
wrapper to access iterator member functions in range-based for
Definition: json.hpp:22498
json_value(const string_t &value)
constructor for strings
Definition: json.hpp:18616
json_value(const binary_t &value)
constructor for binary arrays (internal type)
Definition: json.hpp:18640
ReferenceType get_ref() const
get a reference value (implicit)
Definition: json.hpp:20875
json_value(const array_t &value)
constructor for arrays
Definition: json.hpp:18628
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts elements
Definition: json.hpp:23374
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
Definition: json.hpp:20758
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
Definition: json.hpp:25816
const_iterator end() const noexcept
returns a const iterator to one past the last element
Definition: json.hpp:22271
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
Definition: json.hpp:26430
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition: json.hpp:20516
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
Definition: json.hpp:22588
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements
Definition: json.hpp:23427
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
Definition: json.hpp:18100
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
Definition: json.hpp:20826
friend bool operator>(const_reference lhs, const_reference rhs) noexcept
comparison: greater than
Definition: json.hpp:24192
constexpr const number_integer_t * get_impl_ptr(const number_integer_t *) const noexcept
get a pointer to the value (integer number)
Definition: json.hpp:20417
constexpr const string_t * get_impl_ptr(const string_t *) const noexcept
get a pointer to the value (string)
Definition: json.hpp:20393
void destroy(value_t t)
Definition: json.hpp:18645
json_value(const object_t &value)
constructor for objects
Definition: json.hpp:18622
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
Definition: json.hpp:21851
json_value(typename binary_t::container_type &&value)
constructor for rvalue binary arrays
Definition: json.hpp:18637
json_value(boolean_t v) noexcept
constructor for booleans
Definition: json.hpp:18536
constexpr bool is_boolean() const noexcept
return whether value is a boolean
Definition: json.hpp:20083
iterator end() noexcept
returns an iterator to one past the last element
Definition: json.hpp:22261
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition: json.hpp:23608
void clear() noexcept
clears the contents
Definition: json.hpp:22882
friend bool operator>=(ScalarType lhs, const_reference rhs) noexcept
comparison: greater than or equal
Definition: json.hpp:24260
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition: json.hpp:25395
constexpr bool is_binary() const noexcept
return whether value is a binary array
Definition: json.hpp:20286
static JSON_HEDLEY_RETURNS_NON_NULL T * create(Args &&... args)
helper for exception-safe object creation
Definition: json.hpp:18469
binary_t * binary
binary (stored with pointer to save storage)
Definition: json.hpp:18523
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
Definition: json.hpp:19470
iterator insert(const_iterator pos, basic_json &&val)
inserts element
Definition: json.hpp:23297
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition: json.hpp:25512
reference operator[](size_type idx)
access specified array element
Definition: json.hpp:21191
friend bool operator>(const_reference lhs, ScalarType rhs) noexcept
comparison: greater than
Definition: json.hpp:24203
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
Serializes the given JSON object j to BSON and forwards the corresponding BSON-representation to the ...
Definition: json.hpp:25125
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
Definition: json.hpp:25773
void swap(binary_t &other)
exchanges the values
Definition: json.hpp:23770
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
Definition: json.hpp:17854
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
Definition: json.hpp:25496
::nlohmann::json_pointer< basic_json > json_pointer
JSON Pointer, see nlohmann::json_pointer.
Definition: json.hpp:17779
friend bool operator!=(ScalarType lhs, const_reference rhs) noexcept
comparison: not equal
Definition: json.hpp:24000
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
Definition: json.hpp:25033
const_reverse_iterator rbegin() const noexcept
returns a const reverse iterator to the last element
Definition: json.hpp:22339
void swap(string_t &other)
exchanges the values
Definition: json.hpp:23737
const_reference back() const
access the last element
Definition: json.hpp:21679
friend bool operator<(const_reference lhs, const_reference rhs) noexcept
comparison: less than
Definition: json.hpp:24031
ValueType get_impl(detail::priority_tag< 1 >) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >())))
get a value (explicit); special case
Definition: json.hpp:20621
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
binary (stored with pointer to save storage)
Definition: json.hpp:19370
constexpr bool is_string() const noexcept
return whether value is a string
Definition: json.hpp:20264
number_integer_t * get_impl_ptr(number_integer_t *) noexcept
get a pointer to the value (integer number)
Definition: json.hpp:20411
constexpr bool is_array() const noexcept
return whether value is an array
Definition: json.hpp:20242
iterator insert_iterator(const_iterator pos, Args &&... args)
Definition: json.hpp:23236
basic_json flatten() const
return flattened JSON value
Definition: json.hpp:25843
constexpr const number_float_t * get_impl_ptr(const number_float_t *) const noexcept
get a pointer to the value (floating-point number)
Definition: json.hpp:20441
constexpr const array_t * get_impl_ptr(const array_t *) const noexcept
get a pointer to the value (array)
Definition: json.hpp:20381
friend bool operator>=(const_reference lhs, ScalarType rhs) noexcept
comparison: greater than or equal
Definition: json.hpp:24249
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
Definition: json.hpp:24675
void push_back(basic_json &&val)
add an object to an array
Definition: json.hpp:22961
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
Definition: json.hpp:25252
size_type count(KeyT &&key) const
returns the number of occurrences of a key in a JSON object
Definition: json.hpp:22087
json_value(const typename binary_t::container_type &value)
constructor for binary arrays
Definition: json.hpp:18634
json_value()=default
default constructor (for null values)
constexpr bool is_number() const noexcept
return whether value is a number
Definition: json.hpp:20113
number_float_t number_float
number (floating-point)
Definition: json.hpp:18531
string_t * get_impl_ptr(string_t *) noexcept
get a pointer to the value (string)
Definition: json.hpp:20387
friend std::ostream & operator>>(const basic_json &j, std::ostream &o)
serialize to stream
Definition: json.hpp:24329
std::less< StringType > object_comparator_t
Definition: json.hpp:17964
string_t * string
string (stored with pointer to save storage)
Definition: json.hpp:18521
reference operator+=(initializer_list_t init)
add an object to an object
Definition: json.hpp:23124
::nlohmann::detail::output_adapter_t< CharType > output_adapter_t
Definition: json.hpp:17767
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
Definition: json.hpp:20142
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
Definition: json.hpp:17787
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
Definition: json.hpp:24833
detail::value_t value_t
Definition: json.hpp:17777
number_float_t * get_impl_ptr(number_float_t *) noexcept
get a pointer to the value (floating-point number)
Definition: json.hpp:20435
json_value(binary_t &&value)
constructor for rvalue binary arrays (internal type)
Definition: json.hpp:18643
friend class ::nlohmann::detail::parser
Definition: json.hpp:17723
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
Definition: json.hpp:24933
const_reference operator[](const typename object_t::key_type &key) const
read-only access specified object element
Definition: json.hpp:21341
iterator find(KeyT &&key)
find an element in a JSON object
Definition: json.hpp:22036
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
Definition: json.hpp:19008
const_reference operator[](size_type idx) const
access specified array element
Definition: json.hpp:21254
array_t * array
array (stored with pointer to save storage)
Definition: json.hpp:18519
AllocatorType< basic_json > allocator_type
the allocator type
Definition: json.hpp:17840
basic_json get_impl(detail::priority_tag< 3 >) const
get special-case overload
Definition: json.hpp:20669
nlohmann::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
Definition: json.hpp:18461
JSONSerializer< T, SFINAE > json_serializer
Definition: json.hpp:17781
void push_back(const typename object_t::value_type &val)
add an object to an object
Definition: json.hpp:23050
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(IteratorType first, IteratorType last, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a pair of character iterators
Definition: json.hpp:24435
number_integer_t number_integer
number (integer)
Definition: json.hpp:18527
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
Definition: json.hpp:22151
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition: json.hpp:25379
basic_json patch(const basic_json &json_patch) const
applies a JSON patch
Definition: json.hpp:25941
string_t value(const typename object_t::key_type &key, const char *default_value) const
overload for a default value of type const char*
Definition: json.hpp:21521
basic_json(CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value
Definition: json.hpp:19080
void set_parents()
Definition: json.hpp:18784
basic_json unflatten() const
unflatten a previously flattened JSON value
Definition: json.hpp:25880
reference set_parent(reference j, std::size_t old_capacity=std::size_t(-1))
Definition: json.hpp:18834
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
Definition: json.hpp:18322
reference operator+=(const typename object_t::value_type &val)
add an object to an object
Definition: json.hpp:23075
const_iterator cbegin() const noexcept
returns a const iterator to the first element
Definition: json.hpp:22230
friend bool operator<=(const_reference lhs, ScalarType rhs) noexcept
comparison: less than or equal
Definition: json.hpp:24157
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
Definition: json.hpp:24631
static ::nlohmann::detail::parser< basic_json, InputAdapterType > parser(InputAdapterType adapter, detail::parser_callback_t< basic_json >cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
Definition: json.hpp:17745
json_value(array_t &&value)
constructor for rvalue arrays
Definition: json.hpp:18631
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
Definition: json.hpp:19242
const_reference at(size_type idx) const
access specified array element with bounds checking
Definition: json.hpp:21043
iterator insert(const_iterator pos, const basic_json &val)
inserts element
Definition: json.hpp:23275
constexpr bool is_discarded() const noexcept
return whether value is discarded
Definition: json.hpp:20313
constexpr auto get_impl(detail::priority_tag< 4 >) const noexcept -> decltype(std::declval< const basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
Definition: json.hpp:20682
constexpr bool is_null() const noexcept
return whether value is null
Definition: json.hpp:20061
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
Definition: json.hpp:23641
binary_t * get_impl_ptr(binary_t *) noexcept
get a pointer to the value (binary)
Definition: json.hpp:20447
ObjectType< StringType, basic_json, object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > > > object_t
a type for an object
Definition: json.hpp:18054
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
get a (pointer) value (explicit)
Definition: json.hpp:20717
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
Definition: json.hpp:23204
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
Definition: json.hpp:24928
reference operator+=(const basic_json &val)
add an object to an array
Definition: json.hpp:23024
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
Definition: json.hpp:21948
static ReferenceType get_ref_impl(ThisType &obj)
helper function to implement get_ref()
Definition: json.hpp:20470
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
Definition: json.hpp:19497
static allocator_type get_allocator()
returns the allocator associated with the container
Definition: json.hpp:17862
constexpr const object_t * get_impl_ptr(const object_t *) const noexcept
get a pointer to the value (object)
Definition: json.hpp:20369
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
Definition: json.hpp:20529
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
Definition: json.hpp:22331
an internal type for a backed binary type
Definition: json.hpp:5127
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
Definition: json.hpp:5146
BinaryType container_type
the type of the underlying container
Definition: json.hpp:5130
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
Definition: json.hpp:5138
bool m_has_subtype
Definition: json.hpp:5268
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
Definition: json.hpp:5142
bool operator!=(const byte_container_with_subtype &rhs) const
Definition: json.hpp:5164
void clear_subtype() noexcept
clears the binary subtype
Definition: json.hpp:5260
byte_container_with_subtype() noexcept(noexcept(container_type()))
Definition: json.hpp:5134
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
Definition: json.hpp:5152
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
Definition: json.hpp:5236
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
Definition: json.hpp:5187
constexpr subtype_type subtype() const noexcept
return the binary subtype
Definition: json.hpp:5215
std::uint64_t subtype_type
the type of the subtype
Definition: json.hpp:5132
subtype_type m_subtype
Definition: json.hpp:5267
bool operator==(const byte_container_with_subtype &rhs) const
Definition: json.hpp:5158
deserialization of CBOR, MessagePack, and UBJSON values
Definition: json.hpp:8448
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:8450
bool get_msgpack_array(const std::size_t len)
Definition: json.hpp:10139
binary_reader & operator=(const binary_reader &)=delete
bool get_bson_string(const NumberType len, string_t &result)
Parses a zero-terminated string of length len from the BSON input.
Definition: json.hpp:8602
bool parse_bson_element_internal(const char_int_type element_type, const std::size_t element_type_parse_position)
Read a BSON document element of the given element_type.
Definition: json.hpp:8649
bool parse_bson_array()
Reads an array from the BSON input and passes it to the SAX-parser.
Definition: json.hpp:8765
char_int_type get_ignore_noop()
Definition: json.hpp:10712
bool get_ubjson_high_precision_number()
Definition: json.hpp:10627
binary_reader(InputAdapterType &&adapter) noexcept
create a binary reader
Definition: json.hpp:8464
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:8449
bool get_bson_cstr(string_t &result)
Parses a C-style string from the BSON input.
Definition: json.hpp:8572
bool get_cbor_array(const std::size_t len, const cbor_tag_handler_t tag_handler)
Definition: json.hpp:9472
bool get_msgpack_binary(binary_t &result)
reads a MessagePack byte array
Definition: json.hpp:10028
bool get_cbor_object(const std::size_t len, const cbor_tag_handler_t tag_handler)
Definition: json.hpp:9510
bool get_ubjson_string(string_t &result, const bool get_char=true)
reads a UBJSON string
Definition: json.hpp:10217
SAX json_sax_t
Definition: json.hpp:8454
bool parse_bson_element_list(const bool is_array)
Read a BSON element list (as specified in the BSON-spec)
Definition: json.hpp:8727
bool parse_cbor_internal(const bool get_char, const cbor_tag_handler_t tag_handler)
Definition: json.hpp:8795
bool get_string(const input_format_t format, const NumberType len, string_t &result)
create a string by reading characters from the input
Definition: json.hpp:10780
bool get_cbor_string(string_t &result)
reads a CBOR string
Definition: json.hpp:9283
InputAdapterType ia
input adapter
Definition: json.hpp:10897
bool get_binary(const input_format_t format, const NumberType len, binary_t &result)
create a byte array by reading bytes from the input
Definition: json.hpp:10813
bool parse_ubjson_internal(const bool get_char=true)
Definition: json.hpp:10198
bool unexpect_eof(const input_format_t format, const char *context) const
Definition: json.hpp:10837
binary_reader & operator=(binary_reader &&)=default
bool get_ubjson_size_type(std::pair< std::size_t, char_int_type > &result)
determine the type and size for a container
Definition: json.hpp:10348
std::string get_token_string() const
Definition: json.hpp:10850
bool get_ubjson_value(const char_int_type prefix)
Definition: json.hpp:10389
typename BasicJsonType::string_t string_t
Definition: json.hpp:8452
bool get_msgpack_object(const std::size_t len)
Definition: json.hpp:10161
bool get_bson_binary(const NumberType len, binary_t &result)
Parses a byte array input of length len from the BSON input.
Definition: json.hpp:8623
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
Definition: json.hpp:10863
std::size_t chars_read
the number of characters read
Definition: json.hpp:10903
typename std::char_traits< char_type >::int_type char_int_type
Definition: json.hpp:8456
binary_reader(const binary_reader &)=delete
char_int_type current
the current character
Definition: json.hpp:10900
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
Definition: json.hpp:8485
json_sax_t * sax
the SAX parser
Definition: json.hpp:10909
bool get_ubjson_size_value(std::size_t &result)
Definition: json.hpp:10271
typename InputAdapterType::char_type char_type
Definition: json.hpp:8455
bool parse_bson_internal()
Reads in a BSON-object and passes it to the SAX-parser.
Definition: json.hpp:8547
bool get_number(const input_format_t format, NumberType &result)
Definition: json.hpp:10737
bool get_cbor_binary(binary_t &result)
reads a CBOR byte array
Definition: json.hpp:9378
binary_reader(binary_reader &&)=default
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:8453
char_int_type get()
get next character from the input
Definition: json.hpp:10703
const bool is_little_endian
whether we can assume little endianness
Definition: json.hpp:10906
bool get_msgpack_string(string_t &result)
reads a MessagePack string
Definition: json.hpp:9946
bool get_ubjson_object()
Definition: json.hpp:10552
bool parse_msgpack_internal()
Definition: json.hpp:9566
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:8451
bool get_ubjson_array()
Definition: json.hpp:10490
serialization to CBOR and MessagePack values
Definition: json.hpp:13696
void write_bson_array(const string_t &name, const typename BasicJsonType::array_t &value)
Writes a BSON element with key name and array value.
Definition: json.hpp:14772
void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix)
Definition: json.hpp:14963
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true)
Definition: json.hpp:14394
static std::size_t calc_bson_entry_header_size(const string_t &name, const BasicJsonType &j)
Definition: json.hpp:14602
static constexpr CharType get_ubjson_float_prefix(double)
Definition: json.hpp:15189
void write_bson_entry_header(const string_t &name, const std::uint8_t element_type)
Writes the given element_type and name to the output adapter.
Definition: json.hpp:14617
static std::size_t calc_bson_element_size(const string_t &name, const BasicJsonType &j)
Calculates the size necessary to serialize the JSON value j with its name.
Definition: json.hpp:14806
void write_bson_double(const string_t &name, const double value)
Writes a BSON element with key name and double value value.
Definition: json.hpp:14639
void write_bson_object(const typename BasicJsonType::object_t &value)
Definition: json.hpp:14916
typename BasicJsonType::string_t string_t
Definition: json.hpp:13697
static constexpr CharType get_cbor_float_prefix(float)
Definition: json.hpp:14932
static constexpr CharType to_char_type(InputCharType x) noexcept
Definition: json.hpp:15289
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:13698
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
Definition: json.hpp:13707
static constexpr CharType get_msgpack_float_prefix(double)
Definition: json.hpp:14951
CharType ubjson_prefix(const BasicJsonType &j) const noexcept
determine the type prefix of container values
Definition: json.hpp:15103
void write_bson_integer(const string_t &name, const std::int64_t value)
Writes a BSON element with key name and integer value.
Definition: json.hpp:14689
static CharType to_char_type(std::uint8_t x) noexcept
Definition: json.hpp:15267
void write_bson_string(const string_t &name, const string_t &value)
Writes a BSON element with key name and string value value.
Definition: json.hpp:14657
void write_bson_object_entry(const string_t &name, const typename BasicJsonType::object_t &value)
Writes a BSON element with key name and object value.
Definition: json.hpp:14739
static constexpr CharType get_ubjson_float_prefix(float)
Definition: json.hpp:15184
void write_number(const NumberType n)
Definition: json.hpp:15210
void write_bson_element(const string_t &name, const BasicJsonType &j)
Serializes the JSON value j to BSON and associates it with the key name.
Definition: json.hpp:14854
void write_bson_binary(const string_t &name, const binary_t &value)
Writes a BSON element with key name and binary value value.
Definition: json.hpp:14791
void write_bson_null(const string_t &name)
Writes a BSON element with key name and null value.
Definition: json.hpp:14671
static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t &value)
Definition: json.hpp:14764
void write_bson(const BasicJsonType &j)
Definition: json.hpp:13716
void write_cbor(const BasicJsonType &j)
Definition: json.hpp:13745
static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept
Definition: json.hpp:14707
static constexpr CharType to_char_type(std::uint8_t x) noexcept
Definition: json.hpp:15260
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:13699
void write_bson_unsigned(const string_t &name, const BasicJsonType &j)
Writes a BSON element with key name and unsigned value.
Definition: json.hpp:14717
static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t &value)
Calculates the size of the BSON serialization of the given JSON-object j.
Definition: json.hpp:14901
static constexpr CharType get_msgpack_float_prefix(float)
Definition: json.hpp:14946
void write_bson_boolean(const string_t &name, const bool value)
Writes a BSON element with key name and boolean value value.
Definition: json.hpp:14629
void write_msgpack(const BasicJsonType &j)
Definition: json.hpp:14069
void write_compact_float(const number_float_t n, detail::input_format_t format)
Definition: json.hpp:15226
static std::size_t calc_bson_string_size(const string_t &value)
Definition: json.hpp:14649
static std::size_t calc_bson_integer_size(const std::int64_t value)
Definition: json.hpp:14679
static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t &value)
Definition: json.hpp:14749
static constexpr CharType get_cbor_float_prefix(double)
Definition: json.hpp:14937
general exception of the basic_json class
Definition: json.hpp:2766
const int id
the id of the exception
Definition: json.hpp:2775
static std::string diagnostics(const BasicJsonType &leaf_element)
Definition: json.hpp:2787
static std::string name(const std::string &ename, int id_)
Definition: json.hpp:2781
std::runtime_error m
an exception object as storage for error messages
Definition: json.hpp:2852
const char * what() const noexcept override
returns the explanatory string
Definition: json.hpp:2769
exception indicating errors with iterators
Definition: json.hpp:2989
static invalid_iterator create(int id_, const std::string &what_arg, const BasicJsonType &context)
Definition: json.hpp:2992
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
Definition: json.hpp:11625
bool operator<(const iter_impl &other) const
comparison: smaller
Definition: json.hpp:12088
iter_impl operator-(difference_type i) const
subtract from iterator
Definition: json.hpp:12218
bool operator!=(const IterImpl &other) const
comparison: not equal
Definition: json.hpp:12079
iter_impl const operator--(int)
post-decrement (it–)
Definition: json.hpp:11991
void set_end() noexcept
set the iterator past the last value
Definition: json.hpp:11815
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
Definition: json.hpp:11652
iter_impl & operator--()
pre-decrement (–it)
Definition: json.hpp:12002
difference_type operator-(const iter_impl &other) const
return difference
Definition: json.hpp:12229
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
Definition: json.hpp:11734
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
defines a reference to the type iterated over (value_type)
Definition: json.hpp:11661
reference operator*() const
return a reference to the value pointed to by the iterator
Definition: json.hpp:11854
iter_impl(iter_impl &&) noexcept=default
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
Definition: json.hpp:12141
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
defines a pointer to the type iterated over (value_type)
Definition: json.hpp:11656
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
Definition: json.hpp:11759
pointer operator->() const
dereference the iterator
Definition: json.hpp:11898
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
Definition: json.hpp:11724
iter_impl const operator++(int)
post-increment (it++)
Definition: json.hpp:11940
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
Definition: json.hpp:11749
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:12321
iter_impl operator+(difference_type i) const
add to iterator
Definition: json.hpp:12196
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
Definition: json.hpp:12207
const object_t::key_type & key() const
return the key of an object iterator
Definition: json.hpp:12296
bool operator==(const IterImpl &other) const
comparison: equal
Definition: json.hpp:12043
bool operator>(const iter_impl &other) const
comparison: greater than
Definition: json.hpp:12132
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
Definition: json.hpp:11650
reference value() const
return the value of an iterator
Definition: json.hpp:12312
typename BasicJsonType::object_t object_t
Definition: json.hpp:11634
friend other_iter_impl
allow basic_json to access private members
Definition: json.hpp:11629
iter_impl & operator++()
pre-increment (++it)
Definition: json.hpp:11951
friend BasicJsonType
Definition: json.hpp:11630
reference operator[](difference_type n) const
access to successor
Definition: json.hpp:12258
bool operator<=(const iter_impl &other) const
comparison: less than or equal
Definition: json.hpp:12123
std::bidirectional_iterator_tag iterator_category
Definition: json.hpp:11647
iter_impl & operator+=(difference_type i)
add to iterator
Definition: json.hpp:12150
typename BasicJsonType::array_t array_t
Definition: json.hpp:11635
iter_impl & operator-=(difference_type i)
subtract from iterator
Definition: json.hpp:12187
Definition: json.hpp:4455
IteratorType anchor
the iterator
Definition: json.hpp:4466
std::input_iterator_tag iterator_category
Definition: json.hpp:4461
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
Definition: json.hpp:4462
const string_type empty_str
an empty string (to return a reference for primitive values)
Definition: json.hpp:4474
iteration_proxy_value(IteratorType it) noexcept
Definition: json.hpp:4477
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
Definition: json.hpp:4503
std::size_t array_index_last
last stringified array index
Definition: json.hpp:4470
string_type array_index_str
a string representation of the array index
Definition: json.hpp:4472
IteratorType::reference value() const
return value of the iterator
Definition: json.hpp:4545
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
Definition: json.hpp:4488
std::size_t array_index
an index for arrays (used to create key names)
Definition: json.hpp:4468
iteration_proxy_value & operator*()
dereference operator (needed for range-based for)
Definition: json.hpp:4482
std::ptrdiff_t difference_type
Definition: json.hpp:4457
const string_type & key() const
return key of the iterator
Definition: json.hpp:4509
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
Definition: json.hpp:4497
proxy class for the items() function
Definition: json.hpp:4553
iteration_proxy_value< IteratorType > begin() noexcept
return iterator begin (needed for range-based for)
Definition: json.hpp:4564
iteration_proxy_value< IteratorType > end() noexcept
return iterator end (needed for range-based for)
Definition: json.hpp:4570
IteratorType::reference container
the container to iterate
Definition: json.hpp:4556
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
Definition: json.hpp:4560
Definition: json.hpp:13461
value_type const * value_ref
Definition: json.hpp:13512
json_ref(json_ref &&) noexcept=default
value_type owned_value
Definition: json.hpp:13511
value_type const & operator*() const
Definition: json.hpp:13500
BasicJsonType value_type
Definition: json.hpp:13463
json_ref(Args &&... args)
Definition: json.hpp:13480
json_ref(const value_type &value)
Definition: json.hpp:13469
value_type const * operator->() const
Definition: json.hpp:13505
json_ref(std::initializer_list< json_ref > init)
Definition: json.hpp:13473
json_ref(value_type &&value)
Definition: json.hpp:13465
value_type moved_or_copied() const
Definition: json.hpp:13491
a template for a reverse iterator class
Definition: json.hpp:12363
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
Definition: json.hpp:12372
json_reverse_iterator const operator--(int)
post-decrement (it–)
Definition: json.hpp:12391
typename Base::reference reference
the reference type for the pointed-to element
Definition: json.hpp:12369
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
Definition: json.hpp:12415
json_reverse_iterator & operator+=(difference_type i)
add to iterator
Definition: json.hpp:12403
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
Definition: json.hpp:12367
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
Definition: json.hpp:12376
reference operator[](difference_type n) const
access to successor
Definition: json.hpp:12427
std::ptrdiff_t difference_type
Definition: json.hpp:12365
difference_type operator-(const json_reverse_iterator &other) const
return difference
Definition: json.hpp:12421
json_reverse_iterator operator+(difference_type i) const
add to iterator
Definition: json.hpp:12409
json_reverse_iterator const operator++(int)
post-increment (it++)
Definition: json.hpp:12379
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
Definition: json.hpp:12433
json_reverse_iterator & operator--()
pre-decrement (–it)
Definition: json.hpp:12397
reference value() const
return the value of an iterator
Definition: json.hpp:12440
json_reverse_iterator & operator++()
pre-increment (++it)
Definition: json.hpp:12385
Definition: json.hpp:6548
bool end_array()
Definition: json.hpp:6611
typename BasicJsonType::string_t string_t
Definition: json.hpp:6553
bool binary(binary_t &)
Definition: json.hpp:6586
bool boolean(bool)
Definition: json.hpp:6561
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6550
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6552
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6554
bool key(string_t &)
Definition: json.hpp:6596
bool start_object(std::size_t=std::size_t(-1))
Definition: json.hpp:6591
bool start_array(std::size_t=std::size_t(-1))
Definition: json.hpp:6606
bool end_object()
Definition: json.hpp:6601
bool parse_error(std::size_t, const std::string &, const detail::exception &)
Definition: json.hpp:6616
bool number_integer(number_integer_t)
Definition: json.hpp:6566
bool string(string_t &)
Definition: json.hpp:6581
bool number_unsigned(number_unsigned_t)
Definition: json.hpp:6571
bool null()
Definition: json.hpp:6556
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6551
bool number_float(number_float_t, const string_t &)
Definition: json.hpp:6576
Definition: json.hpp:6241
typename BasicJsonType::string_t string_t
Definition: json.hpp:6246
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
bool start_object(std::size_t len)
Definition: json.hpp:6308
bool key(string_t &val)
Definition: json.hpp:6326
constexpr bool is_errored() const
Definition: json.hpp:6441
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6244
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6243
std::pair< bool, BasicJsonType * > handle_value(Value &&v, const bool skip_callback=false)
Definition: json.hpp:6463
bool null()
Definition: json.hpp:6266
typename BasicJsonType::parser_callback_t parser_callback_t
Definition: json.hpp:6248
bool start_array(std::size_t len)
Definition: json.hpp:6379
~json_sax_dom_callback_parser()=default
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6247
bool binary(binary_t &val)
Definition: json.hpp:6302
bool number_integer(number_integer_t val)
Definition: json.hpp:6278
BasicJsonType & root
the parsed JSON value
Definition: json.hpp:6527
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6245
bool end_array()
Definition: json.hpp:6396
typename BasicJsonType::parse_event_t parse_event_t
Definition: json.hpp:6249
bool boolean(bool val)
Definition: json.hpp:6272
bool number_unsigned(number_unsigned_t val)
Definition: json.hpp:6284
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
bool string(string_t &val)
Definition: json.hpp:6296
bool number_float(number_float_t val, const string_t &)
Definition: json.hpp:6290
bool end_object()
Definition: json.hpp:6343
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition: json.hpp:6429
json_sax_dom_callback_parser(BasicJsonType &r, const parser_callback_t cb, const bool allow_exceptions_=true)
Definition: json.hpp:6251
SAX implementation to create a JSON value from SAX events.
Definition: json.hpp:6067
bool start_array(std::size_t len)
Definition: json.hpp:6159
json_sax_dom_parser(const json_sax_dom_parser &)=delete
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:6073
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool number_unsigned(number_unsigned_t val)
Definition: json.hpp:6109
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6069
bool boolean(bool val)
Definition: json.hpp:6097
~json_sax_dom_parser()=default
bool parse_error(std::size_t, const std::string &, const Exception &ex)
Definition: json.hpp:6179
JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType * handle_value(Value &&v)
Definition: json.hpp:6205
bool string(string_t &val)
Definition: json.hpp:6121
bool end_object()
Definition: json.hpp:6152
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6070
bool start_object(std::size_t len)
Definition: json.hpp:6133
bool null()
Definition: json.hpp:6091
bool binary(binary_t &val)
Definition: json.hpp:6127
constexpr bool is_errored() const
Definition: json.hpp:6191
bool key(string_t &val)
Definition: json.hpp:6145
json_sax_dom_parser(json_sax_dom_parser &&)=default
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6071
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
BasicJsonType & root
the parsed JSON value
Definition: json.hpp:6228
bool number_float(number_float_t val, const string_t &)
Definition: json.hpp:6115
bool end_array()
Definition: json.hpp:6171
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true)
Definition: json.hpp:6080
typename BasicJsonType::string_t string_t
Definition: json.hpp:6072
bool number_integer(number_integer_t val)
Definition: json.hpp:6103
Definition: json.hpp:6655
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
Definition: json.hpp:6682
token_type
token types for the parser
Definition: json.hpp:6659
@ value_float
an floating point number – use get_number_float() for actual value
@ begin_array
the character for array begin [
@ value_string
a string – use get_string() for actual value
@ end_array
the character for array end ]
@ uninitialized
indicating the scanner is uninitialized
@ parse_error
indicating a parse error
@ value_integer
a signed integer – use get_number_integer() for actual value
@ value_separator
the value separator ,
@ end_object
the character for object end }
@ literal_true
the true literal
@ begin_object
the character for object begin {
@ value_unsigned
an unsigned integer – use get_number_unsigned() for actual value
@ literal_null
the null literal
@ end_of_input
indicating the end of the input buffer
@ name_separator
the name separator :
@ literal_or_value
a literal or the begin of a value (only for diagnostics)
@ literal_false
the false literal
lexical analysis
Definition: json.hpp:6732
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
Definition: json.hpp:8050
number_float_t value_float
Definition: json.hpp:8245
const bool ignore_comments
whether comments should be ignored (true) or signaled as errors (false)
Definition: json.hpp:8222
void add(char_int_type c)
add a character to token_buffer
Definition: json.hpp:8021
void reset() noexcept
reset token_buffer; current character is beginning of token
Definition: json.hpp:7940
token_type scan()
Definition: json.hpp:8129
bool next_unget
whether the next get() call should just return current
Definition: json.hpp:8228
char_int_type current
the current character
Definition: json.hpp:8225
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:6735
void skip_whitespace()
Definition: json.hpp:8120
typename std::char_traits< char_type >::int_type char_int_type
Definition: json.hpp:6738
static JSON_HEDLEY_PURE char get_decimal_point() noexcept
return the locale-dependent decimal point
Definition: json.hpp:6763
number_integer_t value_integer
Definition: json.hpp:8243
InputAdapterType ia
input adapter
Definition: json.hpp:8219
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:6733
lexer & operator=(lexer &&)=default
static void strtof(float &f, const char *str, char **endptr) noexcept
Definition: json.hpp:7532
const char_int_type decimal_point_char
the decimal point
Definition: json.hpp:8248
bool skip_bom()
skip the UTF-8 byte order mark
Definition: json.hpp:8106
const char * error_message
a description of occurred lexer errors
Definition: json.hpp:8240
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
Definition: json.hpp:6743
position_t position
the start position of the current token
Definition: json.hpp:8231
constexpr position_t get_position() const noexcept
return position of last read token
Definition: json.hpp:8060
std::vector< char_type > token_string
raw input token string (for error messages)
Definition: json.hpp:8234
constexpr number_integer_t get_number_integer() const noexcept
return integer value
Definition: json.hpp:8032
typename lexer_base< BasicJsonType >::token_type token_type
Definition: json.hpp:6741
typename InputAdapterType::char_type char_type
Definition: json.hpp:6737
char_int_type get()
Definition: json.hpp:7957
token_type scan_number()
scan a number literal
Definition: json.hpp:7589
lexer & operator=(lexer &)=delete
void unget()
unget current character (read it again on next get)
Definition: json.hpp:7994
token_type scan_string()
scan a string literal
Definition: json.hpp:6874
lexer(const lexer &)=delete
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
Definition: json.hpp:8038
string_t token_buffer
buffer for variable-length tokens (numbers, strings)
Definition: json.hpp:8237
token_type scan_literal(const char_type *literal_text, const std::size_t length, token_type return_type)
Definition: json.hpp:7920
constexpr number_float_t get_number_float() const noexcept
return floating-point value
Definition: json.hpp:8044
int get_codepoint()
get codepoint from 4 hex characters following \u
Definition: json.hpp:6789
std::string get_token_string() const
Definition: json.hpp:8068
number_unsigned_t value_unsigned
Definition: json.hpp:8244
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:6734
bool next_byte_in_range(std::initializer_list< char_int_type > ranges)
check if the next byte(s) are inside a given range
Definition: json.hpp:6837
typename BasicJsonType::string_t string_t
Definition: json.hpp:6736
bool scan_comment()
scan a comment
Definition: json.hpp:7464
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
Definition: json.hpp:8093
exception indicating other library errors
Definition: json.hpp:3131
static other_error create(int id_, const std::string &what_arg, const BasicJsonType &context)
Definition: json.hpp:3134
exception indicating access out of the defined range
Definition: json.hpp:3092
static out_of_range create(int id_, const std::string &what_arg, const BasicJsonType &context)
Definition: json.hpp:3095
Definition: json.hpp:13657
output_adapter(std::basic_ostream< CharType > &s)
Definition: json.hpp:13664
output_adapter(std::vector< CharType, AllocatorType > &vec)
Definition: json.hpp:13660
output_adapter(StringType &s)
Definition: json.hpp:13668
output adapter for output streams
Definition: json.hpp:13609
void write_character(CharType c) override
Definition: json.hpp:13615
std::basic_ostream< CharType > & stream
Definition: json.hpp:13627
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
Definition: json.hpp:13611
output adapter for basic_string
Definition: json.hpp:13634
void write_character(CharType c) override
Definition: json.hpp:13640
StringType & str
Definition: json.hpp:13652
output_string_adapter(StringType &s) noexcept
Definition: json.hpp:13636
output adapter for byte vectors
Definition: json.hpp:13584
output_vector_adapter(std::vector< CharType, AllocatorType > &vec) noexcept
Definition: json.hpp:13586
void write_character(CharType c) override
Definition: json.hpp:13590
std::vector< CharType, AllocatorType > & v
Definition: json.hpp:13602
exception indicating a parse error
Definition: json.hpp:2901
parse_error(int id_, std::size_t byte_, const char *what_arg)
Definition: json.hpp:2941
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, const BasicJsonType &context)
Definition: json.hpp:2921
const std::size_t byte
byte index of the parse error
Definition: json.hpp:2938
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, const BasicJsonType &context)
create a parse error exception
Definition: json.hpp:2913
static std::string position_string(const position_t &pos)
Definition: json.hpp:2944
syntax analysis
Definition: json.hpp:10978
lexer_t m_lexer
the lexer
Definition: json.hpp:11418
bool sax_parse(SAX *sax, const bool strict=true)
Definition: json.hpp:11078
token_type get_token()
get next token from lexer
Definition: json.hpp:11378
token_type last_token
the type of the last read token
Definition: json.hpp:11416
parser(InputAdapterType &&adapter, const parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool skip_comments=false)
a parser reading from an input adapter
Definition: json.hpp:10988
bool accept(const bool strict=true)
public accept interface
Definition: json.hpp:11070
typename BasicJsonType::string_t string_t
Definition: json.hpp:10982
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:10980
typename lexer_t::token_type token_type
Definition: json.hpp:10984
bool sax_parse_internal(SAX *sax)
Definition: json.hpp:11097
const parser_callback_t< BasicJsonType > callback
callback function
Definition: json.hpp:11414
void parse(const bool strict, BasicJsonType &result)
public parser interface
Definition: json.hpp:11010
std::string exception_message(const token_type expected, const std::string &context)
Definition: json.hpp:11383
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:10981
const bool allow_exceptions
whether to throw exceptions in case of errors
Definition: json.hpp:11420
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:10979
Definition: json.hpp:11452
primitive_iterator_t operator+(difference_type n) noexcept
Definition: json.hpp:11502
primitive_iterator_t & operator++() noexcept
Definition: json.hpp:11514
constexpr bool is_end() const noexcept
return whether the iterator is at end
Definition: json.hpp:11487
primitive_iterator_t & operator-=(difference_type n) noexcept
Definition: json.hpp:11546
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
Definition: json.hpp:11481
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:11497
void set_begin() noexcept
set iterator to a defined beginning
Definition: json.hpp:11469
primitive_iterator_t const operator++(int) noexcept
Definition: json.hpp:11520
static constexpr difference_type end_value
Definition: json.hpp:11456
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:11492
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
Definition: json.hpp:11509
primitive_iterator_t & operator--() noexcept
Definition: json.hpp:11527
void set_end() noexcept
set iterator to a defined past the end
Definition: json.hpp:11475
constexpr difference_type get_value() const noexcept
Definition: json.hpp:11463
primitive_iterator_t const operator--(int) noexcept
Definition: json.hpp:11533
std::ptrdiff_t difference_type
Definition: json.hpp:11454
primitive_iterator_t & operator+=(difference_type n) noexcept
Definition: json.hpp:11540
static constexpr difference_type begin_value
Definition: json.hpp:11455
Definition: json.hpp:16467
const error_handler_t error_handler
error_handler how to react on decoding errors
Definition: json.hpp:17377
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:16471
const std::lconv * loc
the locale
Definition: json.hpp:17362
std::array< char, 64 > number_buffer
a (hopefully) large enough character buffer
Definition: json.hpp:17359
static constexpr std::uint8_t UTF8_ACCEPT
Definition: json.hpp:16473
serializer(serializer &&)=delete
serializer & operator=(serializer &&)=delete
const char decimal_point
the locale's decimal point character
Definition: json.hpp:17366
std::uint8_t state
Definition: json.hpp:16809
std::size_t bytes
Definition: json.hpp:16810
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:16469
const char thousands_sep
the locale's thousand separator character
Definition: json.hpp:17364
serializer & operator=(const serializer &)=delete
std::size_t undumped_chars
Definition: json.hpp:16814
static constexpr std::uint8_t UTF8_REJECT
Definition: json.hpp:16474
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
Definition: json.hpp:16522
const char indent_char
the indentation character
Definition: json.hpp:17372
std::size_t bytes_after_last_accept
Definition: json.hpp:16813
std::array< char, 512 > string_buffer
string buffer
Definition: json.hpp:17369
typename BasicJsonType::binary_t::value_type binary_char_t
Definition: json.hpp:16472
JSON_PRIVATE_UNLESS_TESTED const bool ensure_ascii
Definition: json.hpp:16807
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
Definition: json.hpp:16482
typename BasicJsonType::string_t string_t
Definition: json.hpp:16468
serializer(const serializer &)=delete
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:16470
string_t indent_string
the indentation string
Definition: json.hpp:17374
exception indicating executing a member function with a wrong type
Definition: json.hpp:3044
static type_error create(int id_, const std::string &what_arg, const BasicJsonType &context)
Definition: json.hpp:3047
JSON Pointer.
Definition: json.hpp:12475
std::vector< std::string > reference_tokens
the reference tokens
Definition: json.hpp:13442
JSON_PRIVATE_UNLESS_TESTED JSON pointer has no BasicJsonType()))
json_pointer & operator/=(std::string token)
append an unescaped reference token at the end of this JSON pointer
Definition: json.hpp:12576
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
Definition: json.hpp:12552
std::string to_string() const
return a string representation of the JSON pointer
Definition: json.hpp:12520
const BasicJsonType & get_unchecked(const BasicJsonType *ptr) const
return a const reference to the pointed to value
Definition: json.hpp:13057
friend bool operator==(json_pointer const &lhs, json_pointer const &rhs) noexcept
compares two JSON pointers for equality
Definition: json.hpp:13418
result reference_tokens
Definition: json.hpp:12841
void pop_back()
remove last reference token
Definition: json.hpp:12702
const std::string & back() const
return last reference token
Definition: json.hpp:12726
const BasicJsonType & get_checked(const BasicJsonType *ptr) const
Definition: json.hpp:13105
bool empty() const noexcept
return whether pointer points to the root document
Definition: json.hpp:12773
friend bool operator!=(json_pointer const &lhs, json_pointer const &rhs) noexcept
compares two JSON pointers for inequality
Definition: json.hpp:13435
void push_back(const std::string &token)
append an unescaped token at the end of the reference pointer
Definition: json.hpp:12748
json_pointer(const std::string &s="")
create JSON pointer
Definition: json.hpp:12502
return result
Definition: json.hpp:12842
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
Definition: json.hpp:12618
bool contains(const BasicJsonType *ptr) const
Definition: json.hpp:13153
static BasicJsonType unflatten(const BasicJsonType &value)
Definition: json.hpp:13380
friend json_pointer operator/(const json_pointer &ptr, std::string token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
Definition: json.hpp:12639
BasicJsonType & get_and_create(BasicJsonType &j) const
create and return a reference to the pointed to value
Definition: json.hpp:12854
static void flatten(const std::string &reference_string, const BasicJsonType &value, BasicJsonType &result)
Definition: json.hpp:13309
void push_back(std::string &&token)
append an unescaped token at the end of the reference pointer
Definition: json.hpp:12754
BasicJsonType & get_checked(BasicJsonType *ptr) const
Definition: json.hpp:13000
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
Definition: json.hpp:12598
static BasicJsonType::size_type array_index(const std::string &s)
Definition: json.hpp:12789
json_pointer result
Definition: json.hpp:12840
BasicJsonType & get_unchecked(BasicJsonType *ptr) const
return a reference to the pointed to value
Definition: json.hpp:12933
friend json_pointer operator/(const json_pointer &ptr, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
Definition: json.hpp:12659
json_pointer parent_pointer() const
returns the parent of this JSON pointer
Definition: json.hpp:12677
static std::vector< std::string > split(const std::string &reference_string)
split the string input to reference tokens
Definition: json.hpp:13241
decltype(get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
Definition: json.hpp:4615
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
Definition: json.hpp:2416
#define JSON_HEDLEY_CONST
Definition: json.hpp:1670
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
Definition: json.hpp:954
#define JSON_HEDLEY_WARN_UNUSED_RESULT
Definition: json.hpp:1300
#define JSON_PRIVATE_UNLESS_TESTED
Definition: json.hpp:2379
#define NLOHMANN_JSON_VERSION_PATCH
Definition: json.hpp:35
#define JSON_HEDLEY_LIKELY(expr)
Definition: json.hpp:1565
#define JSON_HEDLEY_NON_NULL(...)
Definition: json.hpp:1458
#define JSON_INTERNAL_CATCH(exception)
Definition: json.hpp:2346
#define JSON_HEDLEY_RETURNS_NON_NULL
Definition: json.hpp:1899
#define JSON_CATCH(exception)
Definition: json.hpp:2345
#define JSON_ASSERT(x)
Definition: json.hpp:2372
#define JSON_THROW(exception)
Definition: json.hpp:2343
#define NLOHMANN_JSON_VERSION_MAJOR
Definition: json.hpp:33
#define NLOHMANN_BASIC_JSON_TPL
Definition: json.hpp:2425
#define JSON_HEDLEY_UNLIKELY(expr)
Definition: json.hpp:1566
#define JSON_TRY
Definition: json.hpp:2344
#define NLOHMANN_JSON_VERSION_MINOR
Definition: json.hpp:34
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
Definition: json.hpp:2591
#define JSON_HEDLEY_DIAGNOSTIC_POP
Definition: json.hpp:955
#define JSON_EXPLICIT
Definition: json.hpp:2628
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
Definition: json.hpp:1248
#define JSON_HEDLEY_PURE
Definition: json.hpp:1639
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
Definition: json.hpp:16144
JSON_HEDLEY_RETURNS_NON_NULL char * format_buffer(char *buf, int len, int decimal_exponent, int min_exp, int max_exp)
prettify v = buf * 10^decimal_exponent
Definition: json.hpp:16296
Target reinterpret_bits(const Source source)
Definition: json.hpp:15364
boundaries compute_boundaries(FloatType value)
Definition: json.hpp:15505
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
Definition: json.hpp:15808
constexpr int kGamma
Definition: json.hpp:15628
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
Definition: json.hpp:15862
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
Definition: json.hpp:16244
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
Definition: json.hpp:15903
constexpr int kAlpha
Definition: json.hpp:15627
cached_power get_cached_power_for_binary_exponent(int e)
Definition: json.hpp:15644
typename std::enable_if< B, T >::type enable_if_t
Definition: json.hpp:3179
typename T::reference reference_t
Definition: json.hpp:3554
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
Definition: json.hpp:147
static void unescape(std::string &s)
string unescaping as described in RFC 6901 (Sect. 4)
Definition: json.hpp:2688
decltype(T::from_json(std::declval< Args >()...)) from_json_function
Definition: json.hpp:3563
void to_json(BasicJsonType &j, T b) noexcept
Definition: json.hpp:4871
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
Definition: json.hpp:3717
value_t
the JSON type enumeration
Definition: json.hpp:121
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
Definition: json.hpp:3962
make_index_sequence< sizeof...(Ts)> index_sequence_for
Definition: json.hpp:3283
decltype(std::declval< T & >().parse_error(std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
Definition: json.hpp:8319
typename T::pointer pointer_t
Definition: json.hpp:3551
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
Definition: json.hpp:8292
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
Definition: json.hpp:10969
typename T::difference_type difference_type_t
Definition: json.hpp:3548
typename detector< nonesuch, void, Op, Args... >::type detected_t
Definition: json.hpp:2277
void int_to_string(string_type &target, std::size_t value)
Definition: json.hpp:4448
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
Definition: json.hpp:4117
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
Definition: json.hpp:8304
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
Definition: json.hpp:8276
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
Definition: json.hpp:8296
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
Definition: json.hpp:8280
JSON_HEDLEY_RETURNS_NON_NULL char * to_chars(char *first, const char *last, FloatType value)
generates a decimal representation of the floating-point number value in [first, last).
Definition: json.hpp:16381
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
Definition: json.hpp:4994
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
Definition: json.hpp:3714
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
Definition: json.hpp:2290
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
Definition: json.hpp:3165
cbor_tag_handler_t
how to treat CBOR tags
Definition: json.hpp:8420
@ store
store tags as binary type
@ error
throw a parse_error exception in case of a tag
parse_event_t
Definition: json.hpp:10952
@ value
the parser finished reading a JSON value
@ key
the parser read a key of a value in an object
@ array_end
the parser read ] and finished processing a JSON array
@ array_start
the parser read [ and started to process a JSON array
@ object_start
the parser read { and started to process a JSON object
@ object_end
the parser read } and finished processing a JSON object
error_handler_t
how to treat decoding errors
Definition: json.hpp:16459
@ strict
throw a type_error exception in case of invalid UTF-8
@ ignore
ignore invalid UTF-8 sequences
@ replace
replace invalid UTF-8 sequences with U+FFFD
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
Definition: json.hpp:8300
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
Definition: json.hpp:5797
typename T::key_type key_type_t
Definition: json.hpp:3542
std::size_t combine(std::size_t seed, std::size_t h) noexcept
Definition: json.hpp:5297
std::size_t hash(const BasicJsonType &j)
hash a JSON value
Definition: json.hpp:5315
static bool little_endianness(int num=1) noexcept
determine system byte order
Definition: json.hpp:8433
typename utility_internal::Gen< T, N >::type make_integer_sequence
Definition: json.hpp:3267
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
Definition: json.hpp:8284
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
Definition: json.hpp:2286
typename detected_or< Default, Op, Args... >::type detected_or_t
Definition: json.hpp:2283
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
Definition: json.hpp:8311
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 > >, priority_tag< 0 >)
Definition: json.hpp:4306
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
Definition: json.hpp:3976
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
Definition: json.hpp:2271
typename make_void< Ts... >::type void_t
Definition: json.hpp:2233
make_integer_sequence< size_t, N > make_index_sequence
Definition: json.hpp:3275
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
Definition: json.hpp:13579
typename T::mapped_type mapped_type_t
Definition: json.hpp:3539
std::string escape(std::string s)
string escaping as described in RFC 6901 (Sect. 4)
Definition: json.hpp:2674
input_format_t
the supported input formats
Definition: json.hpp:5451
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
Definition: json.hpp:4300
decltype(std::declval< T >().template get< U >()) get_template_function
Definition: json.hpp:3566
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)> >, index_sequence< Idx... >)
Definition: json.hpp:4200
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
Definition: json.hpp:5854
decltype(std::declval< T & >().null()) null_function_t
Definition: json.hpp:8272
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition: json.hpp:4579
void replace_substring(std::string &s, const std::string &f, const std::string &t)
replace all occurrences of a substring by another string
Definition: json.hpp:2656
typename T::iterator_category iterator_category_t
Definition: json.hpp:3557
decltype(std::declval< T & >().number_float(std::declval< Float >(), std::declval< const String & >())) number_float_function_t
Definition: json.hpp:8288
decltype(std::declval< T & >().end_array()) end_array_function_t
Definition: json.hpp:8314
decltype(std::declval< T & >().end_object()) end_object_function_t
Definition: json.hpp:8307
T conditional_static_cast(U value)
Definition: json.hpp:3936
decltype(T::to_json(std::declval< Args >()...)) to_json_function
Definition: json.hpp:3560
typename T::value_type value_type_t
Definition: json.hpp:3545
namespace for Niels Lohmann
Definition: json.hpp:89
basic_json<> json
default JSON class
Definition: json.hpp:3472
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition: json.hpp:26469
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition: json.hpp:26523
default JSONSerializer template argument
Definition: json.hpp:5043
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
Definition: json.hpp:5056
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
Definition: json.hpp:5076
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
Definition: json.hpp:5093
Definition: json.hpp:3628
Op< Args... > type
Definition: json.hpp:2267
std::true_type value_t
Definition: json.hpp:2266
Definition: json.hpp:2258
Default type
Definition: json.hpp:2260
std::false_type value_t
Definition: json.hpp:2259
Definition: json.hpp:15492
diyfp plus
Definition: json.hpp:15495
diyfp w
Definition: json.hpp:15493
diyfp minus
Definition: json.hpp:15494
Definition: json.hpp:15631
std::uint64_t f
Definition: json.hpp:15632
int k
Definition: json.hpp:15634
int e
Definition: json.hpp:15633
Definition: json.hpp:15374
static constexpr int kPrecision
Definition: json.hpp:15375
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
Definition: json.hpp:15463
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
Definition: json.hpp:15480
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
Definition: json.hpp:15398
constexpr diyfp(std::uint64_t f_, int e_) noexcept
Definition: json.hpp:15380
int e
Definition: json.hpp:15378
std::uint64_t f
Definition: json.hpp:15377
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
Definition: json.hpp:15386
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
Definition: json.hpp:4783
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
Definition: json.hpp:4812
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
Definition: json.hpp:4796
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
Definition: json.hpp:4771
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
Definition: json.hpp:4761
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
Definition: json.hpp:4700
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
Definition: json.hpp:4709
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
Definition: json.hpp:4654
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
Definition: json.hpp:4722
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
Definition: json.hpp:4748
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
Definition: json.hpp:4735
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
Definition: json.hpp:4841
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
Definition: json.hpp:4831
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
Definition: json.hpp:4852
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
Definition: json.hpp:4676
static void construct(BasicJsonType &j, const CompatibleStringType &str)
Definition: json.hpp:4687
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
Definition: json.hpp:4667
Definition: json.hpp:4648
Definition: json.hpp:4395
auto operator()(const BasicJsonType &j, T &&val) const noexcept(noexcept(from_json(j, std::forward< T >(val)))) -> decltype(from_json(j, std::forward< T >(val)))
Definition: json.hpp:4397
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3585
Definition: json.hpp:3570
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3600
Definition: json.hpp:3595
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: json.hpp:3615
Definition: json.hpp:3610
Definition: json.hpp:3314
Definition: json.hpp:3207
T value_type
Definition: json.hpp:3208
static constexpr std::size_t size() noexcept
Definition: json.hpp:3209
an iterator value
Definition: json.hpp:11567
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:11573
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:11571
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition: json.hpp:11569
Definition: json.hpp:3516
Definition: json.hpp:3802
Definition: json.hpp:3821
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
Definition: json.hpp:3880
std::numeric_limits< RealIntegerType > RealLimits
Definition: json.hpp:3879
Definition: json.hpp:3869
Definition: json.hpp:3892
typename BasicJsonType::object_t object_t
Definition: json.hpp:3739
Definition: json.hpp:3731
Definition: json.hpp:3751
Definition: json.hpp:3788
static constexpr auto value
Definition: json.hpp:3789
Definition: json.hpp:3895
Definition: json.hpp:3908
Definition: json.hpp:3724
nlohmann::detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value_type range_value_t< ConstructibleArrayType > value_type
Definition: json.hpp:3851
Definition: json.hpp:3824
Definition: json.hpp:3865
typename BasicJsonType::object_t object_t
Definition: json.hpp:3763
Definition: json.hpp:3755
Definition: json.hpp:3784
Definition: json.hpp:3795
static constexpr auto value
Definition: json.hpp:3796
Definition: json.hpp:3911
Definition: json.hpp:3661
Definition: json.hpp:3641
Definition: json.hpp:2274
Definition: json.hpp:3578
static constexpr bool value
Definition: json.hpp:3579
Definition: json.hpp:5773
typename std::iterator_traits< T >::value_type value_type
Definition: json.hpp:5774
Definition: json.hpp:3677
Definition: json.hpp:3529
Definition: json.hpp:3924
char x[2]
Definition: json.hpp:3925
Definition: json.hpp:3920
@ value
Definition: json.hpp:3931
char one
Definition: json.hpp:3921
static one test(decltype(&C::capacity))
Definition: json.hpp:3696
detected_t< result_of_end, t_ref > sentinel
Definition: json.hpp:3701
detected_t< result_of_begin, t_ref > iterator
Definition: json.hpp:3700
static constexpr auto is_iterator_begin
Definition: json.hpp:3706
typename std::add_lvalue_reference< T >::type t_ref
Definition: json.hpp:3698
static constexpr bool value
Definition: json.hpp:3710
Definition: json.hpp:8354
typename BasicJsonType::string_t string_t
Definition: json.hpp:8362
typename BasicJsonType::exception exception_t
Definition: json.hpp:8364
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:8359
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:8361
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:8363
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:8360
Definition: json.hpp:8323
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:8330
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:8329
typename BasicJsonType::exception exception_t
Definition: json.hpp:8333
static constexpr bool value
Definition: json.hpp:8336
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:8328
typename BasicJsonType::string_t string_t
Definition: json.hpp:8331
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:8332
T & reference
Definition: json.hpp:3379
T * pointer
Definition: json.hpp:3378
T value_type
Definition: json.hpp:3376
std::random_access_iterator_tag iterator_category
Definition: json.hpp:3375
ptrdiff_t difference_type
Definition: json.hpp:3377
Definition: json.hpp:3363
typename It::difference_type difference_type
Definition: json.hpp:3352
typename It::reference reference
Definition: json.hpp:3355
typename It::iterator_category iterator_category
Definition: json.hpp:3356
typename It::pointer pointer
Definition: json.hpp:3354
typename It::value_type value_type
Definition: json.hpp:3353
Definition: json.hpp:3344
Definition: json.hpp:2230
void type
Definition: json.hpp:2231
Definition: json.hpp:3635
Definition: json.hpp:2244
nonesuch(nonesuch const &)=delete
void operator=(nonesuch &&)=delete
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch const &)=delete
abstract output adapter interface
Definition: json.hpp:13565
virtual void write_characters(const CharType *s, std::size_t length)=0
virtual void write_character(CharType c)=0
output_adapter_protocol(output_adapter_protocol &&) noexcept=default
virtual ~output_adapter_protocol()=default
output_adapter_protocol(const output_adapter_protocol &)=default
output_adapter_protocol()=default
struct to capture the start position of the current token
Definition: json.hpp:2708
std::size_t lines_read
the number of lines read
Definition: json.hpp:2714
std::size_t chars_read_current_line
the number of characters read in the current line
Definition: json.hpp:2712
std::size_t chars_read_total
the total number of characters read
Definition: json.hpp:2710
Definition: json.hpp:3290
Definition: json.hpp:3296
static constexpr T value
Definition: json.hpp:3297
Definition: json.hpp:5014
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
Definition: json.hpp:5016
Definition: json.hpp:3227
Definition: json.hpp:3246
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
Definition: json.hpp:3248
SAX interface.
Definition: json.hpp:5936
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
virtual bool string(string_t &val)=0
a string was read
virtual bool null()=0
a null value was read
typename BasicJsonType::number_integer_t number_integer_t
Definition: json.hpp:5937
typename BasicJsonType::binary_t binary_t
Definition: json.hpp:5941
virtual bool end_array()=0
the end of an array was read
virtual bool key(string_t &val)=0
an object key was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
Definition: json.hpp:5938
virtual bool binary(binary_t &val)=0
a binary string was read
typename BasicJsonType::number_float_t number_float_t
Definition: json.hpp:5939
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
json_sax(json_sax &&) noexcept=default
virtual bool boolean(bool val)=0
a boolean value was read
json_sax(const json_sax &)=default
virtual bool end_object()=0
the end of an object was read
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
typename BasicJsonType::string_t string_t
Definition: json.hpp:5940
virtual bool number_float(number_float_t val, const string_t &s)=0
an floating-point number was read
virtual bool number_integer(number_integer_t val)=0
an integer number was read
Definition: json.hpp:17409
T & at(const Key &key)
Definition: json.hpp:17450
ordered_map(std::initializer_list< T > init, const Allocator &alloc=Allocator())
Definition: json.hpp:17424
std::vector< std::pair< const Key, T >, Allocator > Container
Definition: json.hpp:17412
T mapped_type
Definition: json.hpp:17411
const T & at(const Key &key) const
Definition: json.hpp:17463
iterator find(const Key &key)
Definition: json.hpp:17560
iterator erase(iterator pos)
Definition: json.hpp:17495
void insert(InputIt first, InputIt last)
Definition: json.hpp:17607
std::pair< iterator, bool > insert(value_type &&value)
Definition: json.hpp:17584
const_iterator find(const Key &key) const
Definition: json.hpp:17572
Key key_type
Definition: json.hpp:17410
size_type erase(const Key &key)
Definition: json.hpp:17476
T & operator[](const Key &key)
Definition: json.hpp:17440
iterator erase(iterator first, iterator last)
Definition: json.hpp:17500
ordered_map(const Allocator &alloc=Allocator())
Definition: json.hpp:17420
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
Definition: json.hpp:17604
ordered_map(It first, It last, const Allocator &alloc=Allocator())
Definition: json.hpp:17422
std::pair< iterator, bool > insert(const value_type &value)
Definition: json.hpp:17589
size_type count(const Key &key) const
Definition: json.hpp:17548
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
Definition: json.hpp:17427
const T & operator[](const Key &key) const
Definition: json.hpp:17445
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
return a hash value for a JSON object
Definition: json.hpp:26491
bool operator()(nlohmann::detail::value_t lhs, nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values
Definition: json.hpp:26507